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.*;
public class Main {

    public static void main(String[] args)  
    {
        
   Scanner ab=new Scanner(System.in);
 int x=ab.nextInt();
 LinkedList<Integer>a4=new LinkedList<>();
 LinkedList<Integer>a8=new LinkedList<>();
 LinkedList<Integer>a15=new LinkedList<>();
 LinkedList<Integer>a16=new LinkedList<>();
 LinkedList<Integer>a23=new LinkedList<>();
 LinkedList<Integer>a42=new LinkedList<>();
 int num[]=new int[x];
 int n=0,n1=0,n2=0,n3=0,n4=0,n5=0,max=0;
 for(int y=0;y<x;y++)
 {
 	num[y]=ab.nextInt();
 	if(num[y]==4){n++;a4.addLast(y);if(n>max)max=n;}
 	else if(num[y]==8){n1++;a8.addLast(y);if(n1>max)max=n1;}
 	else if(num[y]==15){n2++;a15.addLast(y);if(n2>max)max=n2;}
 	else if(num[y]==16){n3++;a16.addLast(y);if(n3>max)max=n3;}
 	else if(num[y]==23){n4++;a23.addLast(y);if(n4>max)max=n4;}
 	else {a42.addLast(y);n5++;if(n5>max)max=n5;}
 }
 
 if(n==0||n1==0||n2==0||n3==0||n4==0||n5==0)System.out.println(x);
 else
 {
 	
int freq[][]=new int[6][]; 	
n=a4.size();
freq[0]=new int[n];
for(int y=0;y<n;y++){freq[0][y]=a4.getFirst();a4.removeFirst();}
n=a8.size();
freq[1]=new int[n];
for(int y=0;y<n;y++){freq[1][y]=a8.getFirst();a8.removeFirst();}
n=a15.size();
freq[2]=new int[n];
for(int y=0;y<n;y++){freq[2][y]=a15.getFirst();a15.removeFirst();}
n=a16.size();
freq[3]=new int[n];
for(int y=0;y<n;y++){freq[3][y]=a16.getFirst();a16.removeFirst();}
n=a23.size();
freq[4]=new int[n];
for(int y=0;y<n;y++){freq[4][y]=a23.getFirst();a23.removeFirst();}
n=a42.size();
freq[5]=new int[n];
for(int y=0;y<n;y++){freq[5][y]=a42.getFirst();a42.removeFirst();}
 
 n=freq[0].length;n1=freq[1].length;n2=freq[2].length;n3=freq[3].length;n4=freq[4].length;n5=freq[0].length;
 
 int cnt=0,index=0;boolean flag=false;
 for(int y=0;y<n;y++)
 {
 	if(flag)break;
 	for(int m=0;m<6;m++)
 	{
 		if(m==0){index=freq[0][y];cnt++;continue;}
 	   if(y>freq[m].length-1){cnt-=m;flag=true;break;}
 		int va=freq[m][y];
 		if(index>va)
 		{
 			for(int i=y+1;i<freq[m].length;i++)
 			{

 			if(freq[m][i]>index){va=freq[m][i];freq[m][i]=0;break;}
 			}
 			
 			if(va>index){index=va;cnt++;}
 			else {flag=true;cnt-=m;break;}

 	   }
 		else {index=freq[m][y];cnt++;}
 	}
 }
 
 System.out.println(x-cnt);
  	
 
 
 
 }
 
    }
}
