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.lang.*;
public class Problem_1176_C{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] a=new int[n];
        int[] val=new int[6*n];
        // for(int i=0;i<n;i++){
        //     val[i]=0;
        // }
        int ans=0;
        int val1=0,val2=1,val3=2,val4=3,val5=4,val6=5;
        for(int i=0;i<n;i++){
            
            a[i]=sc.nextInt();
            if(a[i]==4){
                val[val1]=4;
                val1=val1+6;
            }
            else if(a[i]==8){
                if(val[val2-1]!=0){
                    val[val2]=8;
                    val2=val2+6;
                }
            }
            else if(a[i]==15){
                if(val[val3-1]!=0){
                    val[val3]=15;
                    val3=val3+6;
                }
            }
            else if(a[i]==16){
                if(val[val4-1]!=0){
                    val[val4]=16;
                    val4=val4+6;
                }
            }
            else if(a[i]==23){
                if(val[val5-1]!=0){
                    val[val5]=23;
                    val5=val5+6;
                }
            }
            else{
                if(val[val6-1]!=0){
                    val[val6]=42;
                    val6=val6+6;
                    ans++;
                }
            }
        }
        if(n<=5){
            System.out.println(n);
        }
        else{
            // Arrays.sort(val);
            // for(int i=0;i<6*n;i++){
            //     System.out.println(val[i]);
            // }
            // ans=0;
            // int count=0;
            // for(int i=0;i<6*n;i++){
            //     if(val[i]==0){
            //         break;
            //     }
            //     else{
            //         count++;
            //         if(count==6){
            //             ans++;
            //             count=0;
            //         }
            //     }
            // }
            // System.out.println(ans);
            System.out.println(n-(ans*6));
        }

    }   
}