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
//Author: Patel Rag
//Java version "1.8.0_211"
import java.util.*;
import java.io.*;

public class Main
{
  static class FastReader
  {
    BufferedReader br;
    StringTokenizer st;

    public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); }

    String next()
    {
      while (st == null || !st.hasMoreElements())
      {
        try
        {
          st = new StringTokenizer(br.readLine());
        }
        catch (IOException  e)
        {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() { return Integer.parseInt(next()); }

    long nextLong(){ return Long.parseLong(next()); }

    double nextDouble(){ return Double.parseDouble(next()); }

    float nextFloat() { return Float.parseFloat(next()); }

    boolean nextBoolean() { return Boolean.parseBoolean(next()); }

    String nextLine()
    {
      String str = "";
      try
      {
        str = br.readLine();
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
      return str;
    }
  }
  static long modExp(long x, long n, long mod)    //binary Modular exponentiation
  {
    long result = 1;
    while(n > 0)
    {
        if(n % 2 == 1)
            result = (result%mod * x%mod)%mod;
        x = (x%mod * x%mod)%mod;
        n=n/2;
    }
    return result;
  }
  static long gcd(long a, long b)
  {
    if(a==0) return b;
    return gcd(b%a,a);
  }
  public static void main(String[] args)
  throws IOException
  {
    FastReader fr = new FastReader();
    int n = fr.nextInt();
    if(n < 6)
    {
      System.out.println(n);
      return;
    }
    HashMap<Integer,Integer> map = new HashMap<>();
    map.put(4,0);
    map.put(8,1);
    map.put(15,2);
    map.put(16,3);
    map.put(23,4);
    map.put(42,5);
    int[] pre = new int[6];
    Arrays.fill(pre,0);
    int out = 0;
    for(int i = 0; i < n; i++)
    {
      int val = fr.nextInt();
      if(val == 4) pre[0]++;
      else
      {
        if(pre[map.get(val) - 1] > 0)
        {
          pre[map.get(val) - 1]--;
          pre[map.get(val)]++;
        }
        else
        {
          out++;
        }
      }
    }
    for(int i = 0; i < 5; i++)
    {
      out = out + pre[i]*(i+1);
    }
    System.out.println(out);

  }
}
class pair
{
  public int first;
  public int second;
  public pair(int first,int second)
  {
    this.first = first;
    this.second = second;
  }
  public int first() { return first; }
  public int second() { return second; }
  public void setFirst(int first) { this.first = first; }
  public void setSecond(int second) { this.second = second; }
}
class myComp implements Comparator<pair>
{
  public int compare(pair a,pair b)
  {
    return (a.first - b.first);
  }
}
class BIT       //Binary Indexed Tree aka Fenwick Tree
{
  public long[] m_array;

  public BIT(long[] dat)
  {
    m_array = new long[dat.length + 1];
    Arrays.fill(m_array,0);
    for(int i = 0; i < dat.length; i++)
    {
      m_array[i + 1] = dat[i];
    }
    for(int i = 1; i < m_array.length; i++)
    {
      int j = i + (i & -i);
      if(j < m_array.length)
      {
        m_array[j] = m_array[j] + m_array[i];
      }
    }
  }

  public final long prefix_query(int i)
  {
    long result = 0;
    for(++i; i > 0; i = i - (i & -i))
    {
      result = result + m_array[i];
    }
    return result;
  }

  public final long range_query(int fro, int to)
  {
    if(fro == 0)
    {
      return prefix_query(to);
    }
    else
    {
      return (prefix_query(to) - prefix_query(fro - 1));
    }
  }

  public void update(int i, long add)
  {
    for(++i; i < m_array.length; i = i + (i & -i))
    {
      m_array[i] = m_array[i] + add;
    }
  }
}
