#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[n], i;
  for (i = 0; i < n; i++) cin >> a[i];
  if (n < 6) {
    cout << n;
    return 0;
  }
  int v[6] = {4, 8, 15, 16, 23, 42};
  map<int, int> make_pair;
  int ans = 0;
  map<int, int>::iterator it;
  int f = 0;
  for (i = 0; i < n; i++) {
    if (a[i] == 4) f++;
    make_pair[a[i]]++;
    for (int j = 0; j < 6; j++) {
      if (a[i] > v[j]) {
        if (make_pair[a[i]] > make_pair[v[j]]) {
          make_pair[a[i]]--;
          ans++;
          break;
        }
      }
    }
  }
  int x = make_pair[42];
  for (it = make_pair.begin(); it != make_pair.end(); it++) {
    if (it->second > x) ans += it->second - x;
  }
  cout << ans;
}
