#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3;
const int maxn = 1e9 + 6;
int main() {
  int n, cnt4 = 0, cnt8 = 0, cnt15 = 0, cnt16 = 0, cnt23 = 0, cnt42 = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int t;
    scanf("%d", &t);
    if (t == 4)
      cnt4++;
    else if (t == 8) {
      if (cnt8 < cnt4) cnt8++;
    } else if (t == 15) {
      if (cnt15 < cnt8) cnt15++;
    } else if (t == 16) {
      if (cnt16 < cnt15) cnt16++;
    } else if (t == 23) {
      if (cnt23 < cnt16) cnt23++;
    } else if (t == 42) {
      if (cnt42 < cnt23) cnt42++;
    }
  }
  printf("%d\n", n - 6 * cnt42);
  return 0;
}
