#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, mx = 0, p, min;
  map<int, list<int>> m;
  map<int, list<int>>::iterator itr;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> k;
    m[k].push_back(i);
  }
  list<int>::iterator it;
  min = k = m[4].size();
  int b[] = {0, 4, 8, 15, 16, 23, 42};
  int a[7][k];
  for (int i = 0; i < k; i++) a[0][i] = 0;
  for (int i = 1; i < 7; i++) {
    p = b[i];
    it = m[p].begin();
    for (int j = 0; j < min; j++) {
      while (*it < a[i - 1][j] && it != m[p].end()) it++;
      if (it == m[p].end()) {
        min = j;
        break;
      } else {
        a[i][j] = *it;
      }
      it++;
    }
  }
  n = n - 6 * min;
  cout << n;
}
