#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  map<int, int> m{{4, 0}, {8, 1}, {15, 2}, {16, 3}, {23, 4}, {42, 5}};
  int tmp;
  for (int i = 0; i < n; ++i) {
    cin >> tmp;
    v[i] = m[tmp];
  }
  vector<int> cnt(6);
  for (int i = 0; i < n; ++i) {
    if (!v[i])
      ++cnt[0];
    else if (cnt[v[i] - 1]) {
      --cnt[v[i] - 1];
      ++cnt[v[i]];
    }
  }
  cout << n - 6 * cnt[5] << '\n';
  return 0;
}
