#include <bits/stdc++.h>
using namespace std;
void test() {
  long long i, t, k, j, m, x, c, d, l, mina, maxa, h, w, y, p, sb,
      ans = 0, q, idx, val, cur, r, s, a, b, u, n;
  {
    cin >> n;
    map<long long, long long> m;
    m[4] = 1;
    m[8] = 2;
    m[15] = 3;
    m[16] = 4;
    m[23] = 5;
    m[42] = 6;
    vector<long long> c(7, 0);
    s = 0;
    vector<long long> a(n);
    for (i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] == 4) {
        c[1]++;
      } else {
        if (a[i] != 4 && a[i] != 8 && a[i] != 15 && a[i] != 16 && a[i] != 23 &&
            a[i] != 42) {
          s++;
          continue;
        }
        p = m[a[i]];
        if (c[p] + 1 > c[p - 1]) {
          s++;
        } else
          c[p]++;
      }
    }
    for (i = 5; i >= 1; i--) {
      s += abs(c[i] - c[6]);
    }
    cout << s << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie();
  long long i, t, k, j, m, x, c, d, l, mina, maxa, h, w, y, p, sb,
      ans = 0, q, idx, val, cur, r, s, a, b, u, n;
  t = 1;
  while (t--) {
    test();
  }
}
