#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
vector<int> v;
map<int, int> be, cnt;
int n, a[500005], x[] = {4, 8, 15, 16, 23, 42};
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < 5; i++) be[x[i + 1]] = x[i];
  be[4] = 0;
  cnt[0] = 1e7;
  for (int i = 0; i < n; i++) {
    if (cnt[be[a[i]]] > cnt[a[i]]) cnt[a[i]]++;
  }
  int ans = cnt[x[5]];
  cout << n - ans * 6 << endl;
  return 0;
}
