#include <bits/stdc++.h>
using namespace std;
const int N = 5 * 1e5 + 10;
int n, a[N];
int s[] = {4, 8, 15, 16, 23, 42};
int counts[50];
int mu[7];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  if (n < 6) {
    cout << n << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == s[0]) {
      mu[1]++;
    } else if (a[i] == s[1] && mu[1] > 0 && mu[1] > mu[2]) {
      mu[2]++;
    } else if (a[i] == s[2] && mu[2] > 0 && mu[2] > mu[3]) {
      mu[3]++;
    } else if (a[i] == s[3] && mu[3] > 0 && mu[3] > mu[4]) {
      mu[4]++;
    } else if (a[i] == s[4] && mu[4] > 0 && mu[4] > mu[5]) {
      mu[5]++;
    } else if (a[i] == s[5] && mu[5] > 0 && mu[5] > mu[6]) {
      mu[6]++;
    }
  }
  int cnt = mu[1];
  for (int i = 1; i <= 6; i++) {
    cnt = min(cnt, mu[i]);
  }
  cout << (n - 6 * cnt) << endl;
}
