#include <bits/stdc++.h>
using namespace std;
int next(int n) {
  if (n == 4) return 0;
  if (n == 8) return 1;
  if (n == 15) return 2;
  if (n == 16) return 3;
  if (n == 23) return 4;
  if (n == 42) return 5;
}
int main() {
  int n;
  cin >> n;
  if (n < 6)
    cout << n << endl;
  else {
    int arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    int trk[6];
    int siz = n / 6, st;
    for (int i = 0; i < 6; i++) trk[i] = 0;
    for (int i = 0; i < n; i++) {
      if (arr[i] == 4)
        trk[0]++;
      else {
        if (trk[next(arr[i]) - 1] > 0) {
          trk[next(arr[i]) - 1]--;
          trk[next(arr[i])]++;
        }
      }
    }
    cout << n - trk[5] * 6 << endl;
  }
}
