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.io.*;
import java.lang.reflect.Array;
import java.math.*;
import java.util.*;
import java.util.regex.Pattern;

@SuppressWarnings("Duplicates")
// author @mdazmat9

public class codeforces{
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        int test =1;
       //  test=sc.nextInt();
        for (int ind = 0; ind < test; ind++) {
            int n=sc.nextInt();
            int[] a=intarray(n);
            LinkedList<Integer>[] list=new LinkedList[50];
            for(int i=0;i<50;i++){
                list[i]=new LinkedList<>();
            }
            for(int i=0;i<n;i++){
                list[a[i]].add(i);
            }
            int count=0;
            while (true){
                  int one=-1,two=-1,three=-1,four=-1,five=-1,six=-1;
                  if(list[4].size()>=1){
                      one=list[4].get(0);
                      list[4].removeFirst();
                  }
                  if(one ==-1){
                      break;
                  }
                  //////////////////
                  while (one>two){
                      if(list[8].size()>=1){
                          two=list[8].get(0);
                          list[8].removeFirst();
                      }
                      else {
                          break;
                      }
                  }
                  if(one > two)
                      break;
                    ////////////////////
                while (two>three){
                    if(list[15].size()>=1){
                        three=list[15].get(0);
                        list[15].removeFirst();
                    }
                    else {
                        break;
                    }
                }
                if(two > three)
                    break;
                ///////////////////////
                while (three>four){
                    if(list[16].size()>=1){
                        four=list[16].get(0);
                        list[16].removeFirst();
                    }
                    else {
                        break;
                    }
                }
                if(three > four)
                    break;
                /////////////////
                while (four>five){
                    if(list[23].size()>=1){
                        five=list[23].get(0);
                        list[23].removeFirst();
                    }
                    else {
                        break;
                    }
                }
                if(four > five)
                    break;
                ///////////
                while (five>six){
                    if(list[42].size()>=1){
                        six=list[42].get(0);
                        list[42].removeFirst();
                    }
                    else {
                        break;
                    }
                }
                if(five > six)
                    break;

                count+=6;

            }
            out.println(n-count);


        }

        out.flush();
    }




    static long[] longarray(int n){ long [] a=new long[n];for(int i=0;i<n;i++)a[i]=sc.nextLong();return a; }
    static int[] intarray(int n){ int [] a=new int[n];for(int i=0;i<n;i++)a[i]=sc.nextInt();return a; }
    static ArrayList<Integer> intlist(int n){ArrayList<Integer> list=new ArrayList<>();for(int i=0;i<n;i++)list.add(sc.nextInt());return list; }
    static ArrayList<Long> longlist(int n){ArrayList<Long> list=new ArrayList<>();for(int i=0;i<n;i++)list.add(sc.nextLong());return list; }
    static int[][] read2darray(int n,int m){ int [][] a=new int[n][m];for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ a[i][j]=sc.nextInt(); } }return a; }
    public static double logb( double a, double b ) {return Math.log(a) / Math.log(b); }
    static long fast_pow(long a, long b) {
        if(b == 0) return 1L;
    long val = fast_pow(a, b / 2);
    if(b % 2 == 0) return val * val % abs;
    else return val * val % abs * a % abs;
    }
    static long abs = (long)1e9 + 7;
    static   void shuffle(int[] a) { int n = a.length;for(int i = 0; i < n; i++) { int r = i + (int) (Math.random() * (n - i));int tmp = a[i];a[i] = a[r];a[r] = tmp; } }
    static long gcd(long a , long b) {
        if(b == 0) return a;
        return gcd(b , a % b);
    }
}


class Scanner {
    public BufferedReader reader;
    public StringTokenizer st;
    public Scanner(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        st = null;
    }
    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = reader.readLine();
                if (line == null) return null;
                st = new StringTokenizer(line);
            } catch (Exception e) {
                throw (new RuntimeException());
            }
        }
        return st.nextToken();
    }
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

class OutputWriter {
    BufferedWriter writer;
    public OutputWriter(OutputStream stream) {
        writer = new BufferedWriter(new OutputStreamWriter(stream));
    }
    public void print(int i) throws IOException {
        writer.write(i);
    }
    public void print(String s) throws IOException {
        writer.write(s);
    }
    public void print(char[] c) throws IOException {
        writer.write(c);
    }
    public void close() throws IOException {
        writer.close();
    }
}
