#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int vals[n];
  int ai[6] = {4, 8, 15, 16, 23, 42};
  queue<int> indices[43];
  for (int i = 0; i < n; ++i) {
    cin >> vals[i];
    indices[vals[i]].push(i);
  }
  bool done = 0;
  while (!done) {
    int prev = -1;
    for (int i = 0; i < 6; ++i) {
      if (indices[ai[i]].empty()) {
        done = 1;
        break;
      }
      int ind = indices[ai[i]].front();
      indices[ai[i]].pop();
      while (ind <= prev && !indices[ai[i]].empty()) {
        ind = indices[ai[i]].front();
        indices[ai[i]].pop();
      }
      if (ind <= prev) {
        done = 1;
        break;
      }
      prev = ind;
    }
    if (!done) {
      n -= 6;
    }
  }
  cout << n << "\n";
  return 0;
}
