#include <bits/stdc++.h>
using namespace std;
vector<int> node[100];
int arr[] = {4, 8, 15, 16, 23, 42};
set<int> st[100];
int main() {
  int n;
  cin >> n;
  for (auto i = 0; i < (long long)(n); i++) {
    int x;
    cin >> x;
    st[x].insert(i);
  }
  int curr = 0;
  while (!st[4].empty()) {
    int idx = *st[4].begin();
    st[4].erase(st[4].begin());
    bool flag = true;
    for (auto i = 1; i < (long long)(6); i++) {
      auto it = st[arr[i]].upper_bound(idx);
      if (it == st[arr[i]].end()) {
        flag = false;
        break;
      }
      idx = *it;
      st[arr[i]].erase(it);
    }
    if (!flag) break;
    curr += 6;
  }
  cout << n - curr << '\n';
  return 0;
}
