#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  map<long long, long long> ind, mp;
  ind[4] = 6;
  ind[8] = 5;
  ind[15] = 4;
  ind[16] = 3;
  ind[23] = 2;
  ind[42] = 1;
  long long cnt = 0;
  for (int i = n - 1; i >= 0; i--) {
    mp[ind[arr[i]]]++;
    if (ind[arr[i]] != 1) {
      if (mp[ind[arr[i]]] > mp[ind[arr[i]] - 1]) {
        cnt++;
        mp[ind[arr[i]]]--;
      }
    }
  }
  long long mini = mp[6];
  for (int i = 5; i > 0; i--) {
    cnt += (mp[i] - mini);
  }
  cout << cnt << endl;
  return 0;
}
