#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> p({4, 8, 15, 16, 23, 42});
  vector<int> v(n);
  int i, j, k, l;
  for (i = 0; i < n; i++) {
    cin >> v[i];
    int tt = lower_bound(p.begin(), p.end(), v[i]) - p.begin();
    v[i] = tt;
  }
  vector<int> s(6);
  for (i = 0; i < n; i++) {
    if (v[i] == 0)
      s[0]++;
    else {
      if (s[v[i] - 1] > 0) {
        s[v[i] - 1]--;
        s[v[i]]++;
      }
    }
  }
  cout << n - (6 * s[5]);
}
