#include <bits/stdc++.h>
using namespace std;
const int INF = 10000000;
int visit[7] = {0, 4, 8, 15, 16, 23, 42};
int s[INF], c[10] = {INF};
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 1; j <= 6; j++) {
      if (s[i] == visit[j]) {
        if (c[j - 1] >= c[j] + 1) c[j]++;
      }
    }
  }
  int ans = INF;
  for (int i = 1; i <= 6; i++) {
    ans = min(ans, c[i]);
  }
  cout << n - ans * 6 << endl;
  return 0;
}
