#include <bits/stdc++.h>
using namespace std;
long long q, dp[105][100005], a[555555], b[555555], k, l, m, n, o, p;
map<long long, long long> mp;
vector<long long> adj[555555];
const long long mod = 1e9 + 7;
void solve() {
  long long c[] = {4, 8, 15, 16, 23, 42};
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    for (long long j = 0; j < 6; j++) {
      if (a[i] == c[j]) {
        a[i] = j;
        break;
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    if (!a[i])
      b[0]++;
    else {
      if (b[a[i] - 1]) {
        b[a[i] - 1]--;
        b[a[i]]++;
      }
    }
  }
  cout << n - b[5] * 6 << endl;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  q = 1;
  while (q--) {
    solve();
  }
}
