#include <bits/stdc++.h>
const long long INF = 0x3f3f3f3f3f;
const long long NINF = -INF - 1;
using namespace std;
int a[500010];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int v;
    cin >> v;
    if (v == 4) a[i] = 1;
    if (v == 8) a[i] = 2;
    if (v == 15) a[i] = 3;
    if (v == 16) a[i] = 4;
    if (v == 23) a[i] = 5;
    if (v == 42) a[i] = 6;
  }
  vector<int> c(7);
  c[0] = n;
  for (int i = 0; i < n; ++i) {
    if (c[a[i] - 1] > 0) {
      ++c[a[i]];
      --c[a[i] - 1];
    }
  }
  long long ans = n - 6 * c[6];
  cout << ans << endl;
  return 0;
}
