#include <bits/stdc++.h>
using namespace std;
constexpr long long INF = 1000000000 + 8;
constexpr array<long long, 6> A = {4, 8, 15, 16, 23, 42};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  long long n;
  cin >> n;
  map<long long, long long> d;
  d[4] = 1;
  d[8] = 2;
  d[15] = 3;
  d[16] = 4;
  d[23] = 5;
  d[42] = 6;
  array<long long, 7> mem = {INF};
  for (long long i = 0; i < n; i++) {
    long long tmp;
    cin >> tmp;
    const long long pos = d[tmp];
    if (mem[pos - 1] > 0) {
      mem[pos - 1]--;
      mem[pos]++;
    }
  }
  const long long ans = n - mem[6] * 6;
  cout << ans << endl;
}
