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(input())
t = list(map(int,input().split()))
wyn = 0
el_4 = []
el_8 = []
el_15 = []
el_16 = []
el_23 = []
el_42 = []
ind_el_4 = 0
ind_el_8 = 0
ind_el_15 = 0
ind_el_16 = 0
ind_el_23 = 0
ind_el_42 = 0
curr_el = 0
for x in range(0,len(t),+1):
    if t[x] == 4:
        el_4.append(x)
    elif t[x] == 8:
        el_8.append(x)
    elif t[x] == 15:
        el_15.append(x)
    elif t[x] == 16:
        el_16.append(x)
    elif t[x] == 23:
        el_23.append(x)
    elif t[x] == 42:
        el_42.append(x)
el_4.append(999999999999)
el_8.append(999999999999)
el_15.append(999999999999)
el_16.append(999999999999)
el_23.append(999999999999)
el_42.append(999999999999)
el_4 = list(reversed(el_4))
el_8 = list(reversed(el_8))
el_15 = list(reversed(el_15))
el_16 = list(reversed(el_16))
el_23 = list(reversed(el_23))
el_42 = list(reversed(el_42))
if el_4[-1] == 999999999999 or el_8[-1] == 999999999999 or el_15[-1] == 999999999999 or el_16[-1] == 999999999999 or el_23[-1] == 999999999999 or el_42[-1] == 999999999999:
    print(len(t))
    exit()
while True:
    curr_el = el_4[-1]
    if curr_el == 999999999999:
        break
    to_pop_8 = 1
    to_pop_15 = 1
    to_pop_16 = 1
    to_pop_23 = 1
    to_pop_42 = 1
    for x in range(len(el_8)-1,-1,-1):
        if el_8[x]<curr_el:
            to_pop_8+=1
            wyn+=1
        else:
            curr_el = el_8[x]
            break
    if curr_el == 999999999999:
        wyn-=len(el_8)-1
        break
    for x in range(len(el_15)-1,-1,-1):
        if el_15[x]<curr_el:
            to_pop_15+=1
            wyn += 1
        else:
            curr_el = el_15[x]
            break
    if curr_el == 999999999999:
        wyn -= len(el_15) - 1
        break
    for x in range(len(el_16)-1,-1,-1):
        if el_16[x]<curr_el:
            to_pop_16+=1
            wyn += 1
        else:
            curr_el = el_16[x]
            break
    if curr_el == 999999999999:
        wyn -= len(el_16) - 1
        break
    for x in range(len(el_23)-1,-1,-1):
        if el_23[x]<curr_el:
            to_pop_23+=1
            wyn += 1
        else:
            curr_el = el_23[x]
            break
    if curr_el == 999999999999:
        wyn -= len(el_23) - 1
        break
    for x in range(len(el_42)-1,-1,-1):
        if el_42[x]<curr_el:
            to_pop_42+=1
            wyn += 1
        else:
            curr_el = el_42[x]
            break
    if curr_el == 999999999999:
        wyn -= len(el_42) - 1
        break
    el_4.pop()
    for x in range(to_pop_8):
        el_8.pop()
    for x in range(to_pop_15):
        el_15.pop()
    for x in range(to_pop_16):
        el_16.pop()
    for x in range(to_pop_23):
        el_23.pop()
    for x in range(to_pop_42):
        el_42.pop()
print(wyn+(len(el_4)-1)+(len(el_8)-1)+(len(el_15)-1)+(len(el_23)-1)+(len(el_42)-1)+(len(el_16)-1))