#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ar[n];
  for (int i = 0; i < n; i++) cin >> ar[i];
  int hash[50] = {0};
  for (int i = 0; i < n; i++) {
    if (ar[i] == 4)
      hash[4]++;
    else if (ar[i] == 8 and hash[4] != 0) {
      hash[8]++;
      hash[4]--;
    } else if (ar[i] == 15 and hash[8] != 0) {
      hash[15]++;
      hash[8]--;
    } else if (ar[i] == 16 and hash[15] != 0) {
      hash[16]++;
      hash[15]--;
    } else if (ar[i] == 23 and hash[16] != 0) {
      hash[23]++;
      hash[16]--;
    } else if (ar[i] == 42 and hash[23] != 0) {
      hash[42]++;
      hash[23]--;
    }
  }
  cout << n - 6 * hash[42] << endl;
  return 0;
}
