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
n = int(raw_input())
a = map(int, raw_input().split())
a_res = [4,8,15,16,23,42]
if n<6:
  print(n)
else:
  c=[0]*(n//6)
  k1=n//6
  k=0
  i1,i2,i3,i4,i5,i6=0,0,0,0,0,0
  for j in range(n):
    if a[j]==4:
      if i1<k1 and c[i1]==0:
        c[i1]=4
        i1+=1
      else:
        k+=1
    elif a[j]==8:
      if i2<k1 and c[i2]==4:
        c[i2]=8
        i2+=1
      else:
        k+=1
    elif a[j]==15:
      if i3<k1 and c[i3]==8:
        c[i3]=15
        i3+=1
      else:
        k+=1
    elif a[j]==16:
      if i4<k1 and c[i4]==15:
        c[i4]=16
        i4+=1
      else:
        k+=1
    elif a[j]==23:
      if i5<k1 and c[i5]==16:
        c[i5]=23
        i5+=1
      else:
        k+=1
    elif a[j]==42:
      if i6<k1 and c[i6]==23:
        c[i6]=42
        i6+=1
      else:
        k+=1
  for j in range(k1):
    if c[j]==42:
      continue
    else:
      if c[j]==4:
        k+=1
      elif c[j]==8:
        k+=2
      elif c[j]==15:
        k+=3
      elif c[j]==16:
        k+=4
      elif c[j]==23:
        k+=5
  print(k)