#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long tt = 1;
  while (tt--) {
    long long n;
    cin >> n;
    long long arr[n];
    long long test[] = {4, 8, 15, 16, 23, 42};
    map<long long, long long> mp;
    for (long long i = 0; i < n; i++) {
      cin >> arr[i];
    }
    long long cnt = 0;
    for (long long i = 0; i < 6; i++) mp[test[i]] = 0;
    for (long long i = 0; i < n; i++) {
      mp[arr[i]] += 1;
      for (long long j = 0; j < 6 and test[j] < arr[i]; j++) {
        if (mp[arr[i]] > mp[test[j]]) {
          cnt += 1;
          mp[arr[i]] -= 1;
        }
      }
    }
    long long sum = 0;
    long long mn = INT_MAX;
    for (auto x : mp) mn = min(mn, x.second);
    cout << n - mp.size() * mn << endl;
  }
  return 0;
}
