#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 4) a[i] = 0;
    if (a[i] == 8) a[i] = 1;
    if (a[i] == 15) a[i] = 2;
    if (a[i] == 16) a[i] = 3;
    if (a[i] == 23) a[i] = 4;
    if (a[i] == 42) a[i] = 5;
  }
  vector<int> t({0, 0, 0, 0, 0, 0});
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      t[0]++;
      continue;
    }
    if (t[a[i] - 1] == 0) {
      ans++;
      continue;
    }
    t[a[i] - 1]--;
    t[a[i]]++;
  }
  for (int i = 0; i < 5; i++) ans += t[i] * (i + 1);
  cout << ans << endl;
}
