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
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int x;
  cin >> x;
  vector<int> v(x);
  vector<int> dp(x, 0);
  vector<int> v1, v2, v3, v4, v5, v6;
  for (int i = 0; i < x; i++) {
    cin >> v[i];
    if (v[i] == 4)
      v1.push_back(i);
    else if (v[i] == 8)
      v2.push_back(i);
    else if (v[i] == 15)
      v3.push_back(i);
    else if (v[i] == 16)
      v4.push_back(i);
    else if (v[i] == 23)
      v5.push_back(i);
    else
      v6.push_back(i);
  }
  int i = 0, j = 0, k = 0, l = 0, m = 0, n = 0;
  while (1) {
    if (i == v1.size() || j == v2.size() || k == v3.size() || l == v4.size() ||
        m == v5.size() || n == v6.size())
      break;
    while (j < v2.size() && v2[j] < v1[i]) j++;
    if (j == v2.size()) break;
    while (k < v3.size() && v3[k] < v2[j]) k++;
    if (k == v3.size()) break;
    while (l < v4.size() && v4[l] < v3[k]) l++;
    if (l == v4.size()) break;
    while (m < v5.size() && v5[m] < v4[l]) m++;
    if (m == v5.size()) break;
    while (n < v6.size() && v6[n] < v5[m]) n++;
    if (n == v6.size()) break;
    dp[v1[i]] = 1;
    dp[v2[j]] = 1;
    dp[v3[k]] = 1;
    dp[v4[l]] = 1;
    dp[v5[m]] = 1;
    dp[v6[n]] = 1;
    i++, j++, k++, l++, m++, n++;
  }
  int cnt = 0;
  for (int i = 0; i < x; i++)
    if (dp[i] == 1) cnt++;
  cout << x - cnt << endl;
  return 0;
}
