#include <bits/stdc++.h>
using namespace std;
inline long long gcd(long long a, long long b) {
  return b > 0 ? gcd(b, a % b) : a;
}
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') {
      f = -1;
    }
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const long long maxnum = 1000005;
long long cot[128];
long long a[maxnum];
signed main() {
  long long n = read();
  for (long long i = 1; i <= n; i++) {
    a[i] = read();
    if (a[i] == 4) {
      cot[4]++;
    } else if (a[i] == 8) {
      if (cot[8] < cot[4]) cot[8]++;
    } else if (a[i] == 15) {
      if (cot[15] < cot[8]) cot[15]++;
    } else if (a[i] == 16) {
      if (cot[16] < cot[15]) cot[16]++;
    } else if (a[i] == 23) {
      if (cot[23] < cot[16]) cot[23]++;
    } else if (a[i] == 42) {
      if (cot[42] < cot[23]) cot[42]++;
    }
  }
  long long sum = 0;
  sum = min({cot[4], cot[8], cot[15], cot[16], cot[23], cot[42]});
  cout << n - 6 * sum << endl;
  return 0;
}
