#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> arr{4, 8, 15, 16, 23, 42};
  map<int, int> my_map;
  my_map[4] = 0;
  my_map[8] = 1;
  my_map[15] = 2;
  my_map[16] = 3;
  my_map[23] = 4;
  my_map[42] = 5;
  vector<int> progress(6, 0);
  int del = 0;
  while (n--) {
    int a;
    cin >> a;
    int b = my_map[a];
    if (b == 0) {
      progress[0]++;
    } else {
      if (progress[b - 1] > 0) {
        progress[b - 1]--;
        progress[b]++;
      } else {
        del++;
      }
    }
  }
  cout << del + progress[0] + progress[1] * 2 + progress[2] * 3 +
              progress[3] * 4 + progress[4] * 5
       << endl;
}
