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.OutputStream;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedHashSet;
import java.io.Writer;
import java.math.BigInteger;
import java.io.OutputStreamWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Egor Kulikov (egor@egork.net)
 */
public class Solution {

    public static void main(String[] args) {

        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        Solutio solver = new Solutio();
        int testCount =1;//Integer.parseInt(in.next());
       // int sum=in.readInt(),te=0;
		// if(sum==1)
		for (int i = 1; i <= testCount; i++) 
		{
			solver.solve(i, in, out);
			//System.out.println();
		}
        out.close();
    }
//**********************SOLVE    HERE     EVERYTHING******************************



    //1 2 3 4 5 
    static class Solutio {
    	static long mod=(long)(Math.pow(10, 9)+7);
        public void solve(int testNumber, InputReader in, OutputWriter out) {
        	//Graph<Integer> g=new Graph<Integer>(true);
//        	int n=in.readInt();
//        	int e=in.readInt();
//        	for(int i=0;i<(e);i++)
//        	{
//        		g.add(in.readInt(), in.readInt());
//        	}
//        	g.add(1, 2);
//        	g.add(1, 3);
//        	g.add(1, 4);
//        	g.add(2, 5);
//        	g.add(4, 6);
//        	g.add(4, 8);
//
//        	g.print();
//        	g.bfs(1);
//        	g.dfs(1);
        	
        	int org[]= {4,8,15,16,23,42};
        	int n=in.readInt();
        	if(n<6)
        	{
        		System.out.println(n);
        		return;
        	}
        	int arr[]=new int[n];
        	for(int i=0;i<n;i++)
        		arr[i]=in.readInt();
        	int toremove=0;
        	int dp[]=new int[6];
        	for(int i=0;i<n;i++)
        	{
        		if(arr[i]==4)
        		{
        			dp[0]++;
        		}
        		
        		if(arr[i]==8)
        		{
        			if(dp[0]>=1)
        			{
        				dp[1]++;
        				dp[0]--;
        			}
        			
        		}
        		
        		if(arr[i]==15)
        		{
        		if(dp[1]>=1)
        		{
        			dp[2]++;
        			dp[1]--;
        		}
        			
        			
        		}
        		
        		if(arr[i]==16)
        		{
        			if(dp[2]>=1)
        			{
        				dp[3]++;
        				dp[2]--;
        			}
        			
        			
        		}
        		
        		if(arr[i]==23)
        		{
        			if(dp[3]>=1)
        			{
        				dp[3]--;
        				dp[4]++;
        			}
        			
        			
        		}
        		
        		if(arr[i]==42)
        		{
        			if(dp[4]>=1)
        			{
        				dp[5]++;
        				dp[4]--;
        			}
        			
        		}
        		
        		
        	}
        	int sub=dp[5];
        	//System.out.println(Arrays.toString(dp));
        	int dd=6*sub;
        	System.out.println((n-dd));
        	
        	
        	
        	
        	
        	
            		
        }
        public static long fact(int n)
        {
        	
        	long sum=1;
        	sum=(((n)*(n-1)/2)%mod);
        	return sum;
        }
        
        private static int nextGreaterElementInSortedList(List<Long> arr, long target)  
        {  
            int start = 0, end = arr.size() - 1;  
        
            int ans = -1;  
            while (start <= end) {  
                int mid = (start + end) / 2;  
        
                // Move to right side if target is  
                // greater.  
                if (arr.get(mid) <= target) {  
                    start = mid + 1;  
                }  
        
                // Move left side.  
                else {  
                    ans = mid;  
                    end = mid - 1;  
                }  
            }  
            return ans;  
        }  
       
        
        
    }
    	
        
     


//*********************END        HERE       EVERYTHING*******************************    

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public void readIntArrays(int[]... arrays) {
            for (int i = 0; i < arrays[0].length; i++) {
                for (int j = 0; j < arrays.length; j++) {
                    arrays[j][i] = readInt();
                }
            }
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}

class Node<E>{
	E data;
	int weight;
	Node(E d,int w)
	{
		data=d;
		weight=w;
	}
	
}
class Graph<E>
{
	int size;
	boolean directed;
	HashMap<E,LinkedList<E>> vertex;
	Graph(boolean dir)
	{
		vertex=new HashMap<E,LinkedList<E>>();
		size=0;
		directed=dir;
	}
	
	public void add(E from,E to)
	{
		if(from==to)
			return;
		if(!vertex.containsKey(from) )
		{
			vertex.put(from, new LinkedList<E>());
			size++;
		}
		if(!vertex.containsKey(to))
		{
			vertex.put(to, new LinkedList<E>());
			size++;
		}
		if(directed==false)
		{
			vertex.get(from).add(to);
			vertex.get(to).add(from);
		}
		else
		vertex.get(from).add(to);
		
	}
	
	public void bfs(E start)
	{
		LinkedList<E> visited=new LinkedList<E>();
		Queue<E> vis=new LinkedList<E>();
		vis.add(start);
		visited.add(start);
		while(vis.isEmpty()==false )
		{
			for(int i=0;i<vertex.get(vis.peek()).size();i++)
			{
				if(!visited.contains(vertex.get(vis.peek()).get(i)))
				{
					vis.add(vertex.get(vis.peek()).get(i));
					visited.add(vertex.get(vis.peek()).get(i));
				}
			}
			
			visited.add(vis.peek());
			System.out.print(vis.poll()+"   ");
			
		}
		System.out.println();
	}
	
	public void bfs01(E start)
	{
		LinkedList<E> visited=new LinkedList<E>();
		Deque<E> vis=new LinkedList<E>();
		vis.add(start);
		visited.add(start);
		while(vis.isEmpty()==false )
		{
			for(int i=0;i<vertex.get(vis.peek()).size();i++)
			{
				if(!visited.contains(vertex.get(vis.peek()).get(i)))
				{
					vis.add(vertex.get(vis.peek()).get(i));
					visited.add(vertex.get(vis.peek()).get(i));
				}
			}
			
			visited.add(vis.peek());
			System.out.print(vis.poll()+"   ");
			
		}
		System.out.println();
	}
	
	
	public void dfs(E start)
	{
		
		
	}
	public void print()
	{
		for(E key:vertex.keySet())
			System.out.println(key+" --> "+vertex.get(key));
		
		
	}

	
	
}

