#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(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> cur(7);
  cur[0] = n;
  for (int i = 0; i < n; i++) {
    if (cur[a[i] - 1] > 0) {
      ++cur[a[i]];
      --cur[a[i] - 1];
    }
  }
  cout << n - 6 * cur[6] << endl;
}
