#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("-O3")
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  map<long long int, long long int> m;
  m[8] = 1;
  m[15] = 2;
  m[16] = 3;
  m[23] = 4;
  m[42] = 5;
  long long int n;
  cin >> n;
  long long int x[6] = {0};
  long long int y[n];
  for (long long int a = 0; a < n; a++) {
    cin >> y[a];
    x[m[y[a]]]++;
    if (m[y[a]]) {
      long long int k = m[y[a]] - 1;
      long long int po = x[m[y[a]]];
      po = min(po, x[k]);
      x[m[y[a]]] = po;
    }
  }
  cout << n - x[5] * 6 << endl;
  return 0;
}
