You are given an array a consisting of n integers. Each a_i is one of the six following numbers: 4, 8, 15, 16, 23, 42.

Your task is to remove the minimum number of elements to make this array good.

An array of length k is called good if k is divisible by 6 and it is possible to split it into k/6 subsequences 4, 8, 15, 16, 23, 42.

Examples of good arrays:

  * [4, 8, 15, 16, 23, 42] (the whole array is a required sequence); 
  * [4, 8, 4, 15, 16, 8, 23, 15, 16, 42, 23, 42] (the first sequence is formed from first, second, fourth, fifth, seventh and tenth elements and the second one is formed from remaining elements); 
  * [] (the empty array is good). 



Examples of bad arrays: 

  * [4, 8, 15, 16, 42, 23] (the order of elements should be exactly 4, 8, 15, 16, 23, 42); 
  * [4, 8, 15, 16, 23, 42, 4] (the length of the array is not divisible by 6); 
  * [4, 8, 15, 16, 23, 42, 4, 8, 15, 16, 23, 23] (the first sequence can be formed from first six elements but the remaining array cannot form the required sequence). 

Input

The first line of the input contains one integer n (1 ≤ n ≤ 5 ⋅ 10^5) — the number of elements in a.

The second line of the input contains n integers a_1, a_2, ..., a_n (each a_i is one of the following numbers: 4, 8, 15, 16, 23, 42), where a_i is the i-th element of a.

Output

Print one integer — the minimum number of elements you have to remove to obtain a good array.

Examples

Input


5
4 8 15 16 23


Output


5


Input


12
4 8 4 15 16 8 23 15 16 42 23 42


Output


0


Input


15
4 8 4 8 15 16 8 16 23 15 16 4 42 23 42


Output


3
	import java.util.*;
	import java.io.*;
	
			public class codeforces
			{	
				public static void main(String[] args)
				{
					InputReader in = new InputReader(System.in);
					PrintWriter pw = new PrintWriter(System.out);

					int n = in.nextInt();
					HashMap<Integer, Integer> map = new HashMap<>();
					ArrayList<Integer>[] list = new ArrayList[n/6];
					
					for(int i=0;i<n/6;i++)
						list[i] = new ArrayList<Integer>();
					
					for(int i=0;i<n;i++)
					{
						int x = in.nextInt();
						
						if(!map.containsKey(x))
							map.put(x, 1);
						else 
							map.put(x, map.get(x)+1);
						
						if(map.get(x)-1 < n/6)
						{
							if(x == 8)
							{
								if(list[map.get(x)-1].size() == 1 && list[map.get(x)-1].get(0) == 4)
									list[map.get(x)-1].add(x);
								else
									map.put(x, map.get(x)-1);
							}
							else if(x == 15)
							{
								if(list[map.get(x)-1].size() == 2 && list[map.get(x)-1].get(1) == 8)
									list[map.get(x)-1].add(x);
								else
									map.put(x, map.get(x)-1);
							}
							else if(x == 16)
							{
								if(list[map.get(x)-1].size() == 3 && list[map.get(x)-1].get(2) == 15)
									list[map.get(x)-1].add(x);
								else
									map.put(x, map.get(x)-1);
							}
							else if(x == 23)
							{
								if(list[map.get(x)-1].size() == 4 && list[map.get(x)-1].get(3) == 16)
									list[map.get(x)-1].add(x);
								else
									map.put(x, map.get(x)-1);
							}
							else if(x == 42)
							{
								if(list[map.get(x)-1].size() == 5 && list[map.get(x)-1].get(4) == 23)
									list[map.get(x)-1].add(x);
								else
									map.put(x, map.get(x)-1);
							}
							else
							{
								if(list[map.get(x)-1].isEmpty())
									list[map.get(x)-1].add(x);
							}
						}
					}
					
					int count = 0;
					
					for(int i=0;i<n/6;i++)
					{//pw.println(list[i]);
						if(list[i].size() == 6)
						{
							if(list[i].get(0) == 4 && list[i].get(1) == 8 && list[i].get(2) == 15 && list[i].get(3) == 16 && list[i].get(4) == 23 && list[i].get(5) == 42)
								count++;
						}
					}
					
					int ans = n - 6*count;
					
					pw.println(ans);
					pw.flush();
					pw.close();
				}
				
				public static int[] suffle(int[] a,Random gen)
				{
					int n = a.length;
					for(int i=0;i<n;i++)
					{
						int ind = gen.nextInt(n-i)+i;
						int temp = a[ind];
						a[ind] = a[i];
						a[i] = temp;
					}
					return a;
				}
				
				public static long modularExponentiation(long x,long n,long M)
				{
				    long result=1;
				    while(n>0)
				    {
				        if(n % 2 ==1)
				            result=(result * x)%M;
				        x=(x*x)%M;
				        n=n/2;
				    }
				    return result;
				}
				
				public static long modInverse(long A,long M)
				{
				    return modularExponentiation(A,M-2,M);
				}
				
				public static int BinarySearch_l(long[] a, long k)
				{
					int n = a.length;
					int i = 0, j = n-1;
					int mid = 0;
					
					if(k - a[n-1] > 0)
						return n;
					else
					{
						while(j - i > 0)
						{
							mid = (i+j)/2;
							
							if(k - a[mid] > 0)
								i = mid + 1;
							else
								j = mid;
						}
					}
					
					return i;
				}
				
				public static int BinarySearch_r(long[] a, long k)
				{
					int n = a.length;
					int i = 0, j = n-1;
					int mid = 0;
					
					if(k - a[0] < 0)
						return -1;
					else
					{
						while(j - i > 0)
						{
							mid = (int)Math.ceil((double)(i+j)/2);
							
							if(k - a[mid] >= 0)
								i = mid;
							else
								j = mid - 1;
						}
					}
					
					return i;
				}
				public static long fact(long n, long M)
				{
					long ans = 1;
					
					for(long i=n;i>0;i--)
					{
						ans = (ans*i)%M;
					}
					
					return ans;
				}
				
			/*	public static void DFS(int sourse)
				{
					int count = 0;
					visited[sourse] = true;
					
					for(int u : adj[sourse])
					{
						if(!visited[u])
						{
							DFS(u);
						}
					}
					
					
				}*/
				
				public static ArrayList Divisors(int n)
				{
				    ArrayList<Integer> div = new ArrayList<>();
				    
				    for (int i=1; i<=Math.sqrt(n); i++)
				    {
				        if (n%i == 0)
				        {
				        	div.add(i);
				                
				            if(n/i != i)
				            	div.add(n/i);
				        }
				    }
				    return div;
				}
			
				public static long GCD(long a,long b)
				{
					if(b==0)
						return a;
					else
						return GCD(b,a%b);
				}
				
				public static long LCM(long a,long b)
				{
					return (a*b)/GCD(a, b);
				}
				
				static class pair implements Comparable<pair>
				{
					Integer x, y;
					pair(int x,int y)
					{
						this.x=x;
						this.y=y;
					}
					
					public int compareTo(pair o) {
						int result = x.compareTo(o.x);
						if(result==0)
							result = y.compareTo(o.y);
						
						return result;
					}  
					
					public String toString()
					{
						return x+" "+y;
					}
					
					public boolean equals(Object o)
					{
						if (o instanceof pair)
					    {
							pair p = (pair)o;
							return p.x - x == 0 && p.y - y == 0 ;
						}
						return false;
					}
					
					public int hashCode()
					{
						return new Long(x).hashCode()*31 + new Long(y).hashCode();
					}
				}
				
				static class InputReader 
				{
					 
					private final InputStream stream;
					private final byte[] buf = new byte[8192];
					private int curChar, snumChars;
					private SpaceCharFilter filter;
			 
					public InputReader(InputStream stream) 
					{
						this.stream = stream;
					}
			 
					public int snext() 
					{
						if (snumChars == -1)
							throw new InputMismatchException();
						if (curChar >= snumChars) 
						{
							curChar = 0;
							try 
							{
								snumChars = stream.read(buf);
							} 
							catch (IOException e) 
							{
								throw new InputMismatchException();
							}
							if (snumChars <= 0)
								return -1;
						}
						return buf[curChar++];
					}
			 
					public int nextInt() 
				    {
						int c = snext();
						while (isSpaceChar(c)) 
						{
							c = snext();
						}
						int sgn = 1;
						if (c == '-')
					    {
							sgn = -1;
							c = snext();
						}
						int res = 0;
						do 
						{
							if (c < '0' || c > '9')
								throw new InputMismatchException();
							res *= 10;
							res += c - '0';
							c = snext();
						} while (!isSpaceChar(c));
						return res * sgn;
					}
			 
					public long nextLong()
				    {
						int c = snext();
						while (isSpaceChar(c)) 
						{
							c = snext();
						}
						int sgn = 1;
						if (c == '-') 
						{
							sgn = -1;
							c = snext();
						}
						long res = 0;
						do 
						{
							if (c < '0' || c > '9')
								throw new InputMismatchException();
							res *= 10;
							res += c - '0';
							c = snext();
						} while (!isSpaceChar(c));
						return res * sgn;
					}
			 
					public int[] nextIntArray(int n) 
					{
						int a[] = new int[n];
						for (int i = 0; i < n; i++) 
						{
							a[i] = nextInt();
						}
						return a;
					}
			 
					public String readString()
				    {
						int c = snext();
						while (isSpaceChar(c)) 
						{
							c = snext();
						}
						StringBuilder res = new StringBuilder();
						do 
						{
							res.appendCodePoint(c);
							c = snext();
						} while (!isSpaceChar(c));
						return res.toString();
					}
			 
					public String nextLine() 
					{
						int c = snext();
						while (isSpaceChar(c))
							c = snext();
						StringBuilder res = new StringBuilder();
						do 
						{
							res.appendCodePoint(c);
							c = snext();
						} while (!isEndOfLine(c));
						return res.toString();
					}
			 
					public boolean isSpaceChar(int c) 
					{
						if (filter != null)
							return filter.isSpaceChar(c);
						return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
					}
			 
					private boolean isEndOfLine(int c) 
					{
						return c == '\n' || c == '\r' || c == -1;
					}
			 
					public interface SpaceCharFilter
				    {
						public boolean isSpaceChar(int ch);
					}
				}
				
				static class CodeX {
		        public static void sort(long arr[]) {
		            merge_sort(arr, 0, arr.length - 1);
		        }
		
		        private static void merge_sort(long A[], long start, long end) {
		            if (start < end) {
		                long mid = (start + end) / 2;
		                merge_sort(A, start, mid);
		                merge_sort(A, mid + 1, end);
		                merge(A, start, mid, end);
		            }
		
		        }
		
		        private static void merge(long A[], long start,long mid, long end) {
		            long p = start, q = mid + 1;
		            long Arr[] = new long[(int)(end - start + 1)];
		            long k = 0;
		
		            for (int i = (int)start; i <= end; i++) {
		                if (p > mid)
		                    Arr[(int)k++] = A[(int)q++];
		
		                else if (q > end)
		                    Arr[(int)k++] = A[(int)p++];
		
		                else if (A[(int)p] < A[(int)q])
		                    Arr[(int)k++] = A[(int)p++];
		
		                else
		                    Arr[(int)k++] = A[(int)q++];
		            }
		            for (int i = 0; i < k; i++) {
		                A[(int)start++] = Arr[i];
		            }
		
		        }
		
		    }
			}	
			
	
				