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 Example {
    static long[][] dp;
    //  static    int[]  ar;
    static int mod = 1000000000 + 7;
    static long[] ans = new long[100000 + 1];
    static  List<List<Integer>> adj;
    static  int[] vis;
    static int[]  dis;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 4,8,15,16,23,42.
        long n =sc.nextInt();
        long[] frq= new long[6];

        for(int i=0;i<n;i++){
            int a=sc.nextInt();
            if(a==4)
                frq[0]++;
            if(a==8 && frq[0]>frq[1])
                frq[1]++;
            if(a==15 && frq[1]>frq[2])
                frq[2]++;
            if(a==16 && frq[2]>frq[3])
                frq[3]++;
            if(a==23&& frq[3]>frq[4])
                frq[4]++;
            if(a==42 && frq[4]>frq[5])
                frq[5]++;
        }

      //  System.out.println(Arrays.toString(frq));
        System.out.println(n-(frq[5]*6));





























    }

    private static long findans(int[] arr, int i, int s) {
        if(i<0 && s==0)
            return 0;
        if(i<0 && s==1)
            return 0;
        if(dp[i][s]!=-1){
            return dp[i][s];
        }
        else{


            if(s==0)
                return dp[i][s]= Math.max(findans(arr,i-1,s),-1*arr[i]+findans(arr,i-1,1-s));
            else
                return dp[i][s]= Math.max(findans(arr,i-1,s),arr[i]+findans(arr,i-1,1-s));
        }
    }

    public static void dfs(int v,int di){
        dis[v]=di;
        vis[v]=1;
        for(int i=0;i<adj.get(v).size();i++){
            int x=adj.get(v).get(i);
            if(vis[x]==0){
                dfs(x,di+1);
            }
        }
    }

    private static boolean isPrime(long a) {
        if (a == 1)
            return true;

        for (int i = 2; i * i <= a; i++) {
            if (a % i == 0)
                return false;

        }
        return true;
    }

    private static int gcd(int aa, int bb) {
        if (bb == 0)
            return aa;
        return gcd(bb, aa % bb);

    }

    private static int lowerBound(int[] ar, int a) {
        int res = 0;
        int s = 1;
        int e = ar.length - 1;
        while (s <= e) {
            int mid = (s) + (e - s) / 2;
            if (ar[mid] <= a) {
                res = mid;
                s = mid + 1;

            } else {
                e = mid - 1;
            }
        }
        return res;
    }

    public static int getXORSum(int[] arr1, int[] arr2) {

        long c = 0;
        int n = arr1.length;
        int m = arr2.length;
        if (n == 1 && m == 1) {
            return arr1[0] & arr2[0];
        }
        int aa = n + m;
        for (int i = 0; i < 32; i++) {

            int z = 0;
            int o = 0;
            int cc = 0;
            for (int a : arr1) {


                int x = (a & (1 << i));
                if (x == 0)
                    z++;
                else
                    o++;


            }
            for (int a : arr2) {
                int x = (a & (1 << i));
                if (x == 0)
                    z++;
                else
                    o++;
            }

            System.out.println(z + " " + o);

            if (z != aa && o != aa) {
                c = c + (1 << i);

            }


        }
        return (int) c;


    }


}


