#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c = 0, num[6] = {0, 0, 0, 0, 0, 0};
  cin >> n;
  map<int, int> ord;
  ord[4] = 0;
  ord[8] = 1;
  ord[15] = 2;
  ord[16] = 3;
  ord[23] = 4;
  ord[42] = 5;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    a = ord[a];
    if (a == 0)
      num[0]++;
    else if (num[a - 1] > 0) {
      num[a - 1]--;
      num[a]++;
    } else
      c++;
  }
  for (int i = 0; i < 5; i++) {
    c += num[i] * (i + 1);
  }
  cout << c << endl;
  return 0;
}
