#include <bits/stdc++.h>
using namespace std;
int n;
int a[500005];
vector<int> pos[6];
int cnt[6], starts[6];
map<int, int> mp, rev_mp;
int main() {
  cin >> n;
  mp[4] = 0;
  rev_mp[0] = 4;
  mp[8] = 1;
  rev_mp[1] = 8;
  mp[15] = 2;
  rev_mp[2] = 15;
  mp[16] = 3;
  rev_mp[3] = 16;
  mp[23] = 4;
  rev_mp[4] = 23;
  mp[42] = 5;
  rev_mp[5] = 42;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    pos[mp[a[i]]].push_back(i);
    cnt[mp[a[i]]]++;
  }
  int mn = min(cnt[0], cnt[1]);
  mn = min(mn, cnt[2]);
  mn = min(mn, cnt[3]);
  mn = min(mn, cnt[4]);
  mn = min(mn, cnt[5]);
  int i;
  for (i = 0; i < mn; i++) {
    int cur = pos[0][i];
    int j = 1;
    bool poss = true;
    while (j < 6 && poss) {
      vector<int>::iterator it =
          upper_bound(pos[j].begin() + starts[j], pos[j].end(), cur);
      if (it == pos[j].end()) {
        poss = false;
      } else {
        int ind = it - pos[j].begin();
        starts[j] = ind + 1;
        cur = pos[j][ind];
      }
      j++;
    }
    if (!poss) break;
  }
  cout << (n - (i * 6)) << endl;
  return 0;
}
