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;
long long fast_power(long long base, long long power,
                     long long m = 1000000007) {
  long long result = 1;
  while (power > 0) {
    if (power % 2 == 1) {
      result = (result * base) % m;
    }
    base = (base * base) % m;
    power = power / 2;
  }
  return result;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int operation(long long int var1, long long int var2) {
  return min(var1, var2);
}
void build(long long int n, long long int l, long long int r,
           long long int tree[], long long int a[]) {
  if (l == r) {
    tree[n] = a[l];
  } else {
    build(2 * n, l, (l + r) / 2, tree, a);
    build(2 * n + 1, (l + r) / 2 + 1, r, tree, a);
    tree[n] = operation(tree[2 * n], tree[2 * n + 1]);
  }
}
void update(long long int n, long long int l, long long int r,
            long long int tree[], long long int a[], long long int node,
            long long int update_value) {
  if (node >= l && node <= r) {
    if (l == r) {
      if (l == node) {
        tree[n] = update_value;
      }
    } else {
      update(2 * n, l, (l + r) / 2, tree, a, node, update_value);
      update(2 * n + 1, (l + r) / 2 + 1, r, tree, a, node, update_value);
      tree[n] = operation(tree[2 * n], tree[2 * n + 1]);
    }
  }
}
void query(long long int n, long long int l, long long int r,
           long long int tree[], long long int a[], long long int ql,
           long long int qr, long long int& min_value) {
  if (l >= ql && r <= qr) {
    min_value = operation(min_value, tree[n]);
  } else if ((l <= ql && ql <= r) || (l <= qr && qr <= r)) {
    query(2 * n, l, (l + r) / 2, tree, a, max(ql, l), min(qr, r), min_value);
    query(2 * n + 1, (l + r) / 2 + 1, r, tree, a, max(ql, l), min(qr, r),
          min_value);
  }
}
long long int tree[1000000];
map<int, vector<int> > adj;
map<int, int> depth;
int dia;
int dfs(int node, int parent) {
  int len = 0;
  for (int next : adj[node]) {
    if (next == parent) continue;
    depth[next] = depth[node] + 1;
    int cur = dfs(next, node) + 1;
    dia = max(dia, cur + len);
    len = max(cur, len);
  }
  return len;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  map<int, bool> bm;
  bm[4] = true;
  bm[8] = true;
  bm[15] = true;
  bm[16] = true;
  bm[23] = true;
  bm[42] = true;
  map<int, queue<int> > make_pair;
  int n;
  cin >> n;
  for (int i = 0; i < (n); i++) {
    int k;
    cin >> k;
    if (bm[k]) {
      make_pair[k].push(i);
    }
  }
  int ans = 0;
  while (!make_pair[4].empty()) {
    int i4 = make_pair[4].front();
    make_pair[4].pop();
    cout << "";
    while (!make_pair[8].empty()) {
      int i8 = make_pair[8].front();
      make_pair[8].pop();
      if (i8 > i4) {
        cout << "";
        while (!make_pair[15].empty()) {
          int i15 = make_pair[15].front();
          make_pair[15].pop();
          if (i15 > i8) {
            cout << "";
            while (!make_pair[16].empty()) {
              int i16 = make_pair[16].front();
              make_pair[16].pop();
              if (i16 > i15) {
                cout << "";
                while (!make_pair[23].empty()) {
                  int i23 = make_pair[23].front();
                  make_pair[23].pop();
                  if (i23 > i16) {
                    cout << "";
                    while (!make_pair[42].empty()) {
                      int i42 = make_pair[42].front();
                      make_pair[42].pop();
                      if (i42 > i23) {
                        cout << "";
                        ans++;
                        break;
                      }
                    }
                    break;
                  }
                }
                break;
              }
            }
            break;
          }
        }
        break;
      }
    }
  }
  cout << n - ans * 6 << "\n";
  return 0;
}
