#include <bits/stdc++.h>
using namespace std;
using namespace std;
int a[50005];
int pre[50005];
int t, n, m, k, num1, num2, num3;
int main() {
  pre[8] = 4;
  pre[15] = 8;
  pre[16] = 15;
  pre[23] = 16;
  pre[42] = 23;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t;
    if (t == 4) {
      a[4]++;
    } else {
      if (a[pre[t]]) {
        a[pre[t]]--;
        a[t]++;
      }
    }
  }
  cout << n - a[42] * 6 << endl;
  return 0;
}
