#include <bits/stdc++.h>
using namespace std;
void sol() {
  long long int n;
  cin >> n;
  vector<int> ar[6];
  long long int a;
  vector<int> v = {4, 8, 15, 16, 23, 42};
  for (long long int i = 0; i < n; i++) {
    cin >> a;
    ar[lower_bound(v.begin(), v.end(), a) - v.begin()].push_back(i);
  }
  int p[6] = {0, 0, 0, 0, 0, 0};
  int sit = 0;
  int cnt = 0;
  while (1) {
    int prev = -1;
    for (long long int i = 0; i < 6; i++) {
      while (p[i] < ar[i].size() && ar[i][p[i]] < prev) {
        p[i]++;
      }
      if (p[i] >= ar[i].size()) {
        sit = 1;
        break;
      }
      prev = ar[i][p[i]];
      p[i]++;
    }
    if (sit == 1)
      break;
    else
      cnt++;
  }
  cout << n - 6 * cnt << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    sol();
  }
  return 0;
}
