#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  scanf("%lld", &n);
  vector<long long> input(n);
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &input[i]);
  }
  if (n == 0) {
    printf("0");
    return 0;
  }
  map<int, long long> m;
  m[4] = 0;
  m[8] = 0;
  m[15] = 0;
  m[16] = 0;
  m[23] = 0;
  m[42] = 0;
  for (long long i = 0; i < n; i++) {
    for (auto subIt = m.begin(); subIt != m.end(); ++subIt) {
      if (input[i] == subIt->first) {
        long long minCount = 9223372036854775807;
        for (auto subIt2 = m.begin(); subIt2 != subIt; ++subIt2) {
          minCount = (minCount < subIt2->second) ? minCount : subIt2->second;
        }
        if (subIt->second + 1 <= minCount) {
          subIt->second++;
        }
      }
    }
  }
  long long numSub = m[42];
  long long extra = 0;
  long long marked = 0;
  for (auto it = m.begin(); it != m.end(); ++it) {
    marked += it->second;
    extra += (it->second - numSub);
  }
  long long unmarked = n - marked;
  printf("%lld", extra + unmarked);
  return 0;
}
