#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, num;
  cin >> n;
  queue<pair<int, int> > q[6];
  int cnt = 0;
  for (i = 0; i < n; i++) {
    cin >> num;
    if (num == 4)
      q[0].push(pair<int, int>(num, i));
    else if (num == 8) {
      if (q[0].size()) {
        q[0].pop();
        q[1].push(pair<int, int>(num, i));
      } else
        cnt++;
    } else if (num == 15) {
      if (q[1].size()) {
        q[1].pop();
        q[2].push(pair<int, int>(num, i));
      } else
        cnt++;
    } else if (num == 16) {
      if (q[2].size()) {
        q[2].pop();
        q[3].push(pair<int, int>(num, i));
      } else
        cnt++;
    } else if (num == 23) {
      if (q[3].size()) {
        q[3].pop();
        q[4].push(pair<int, int>(num, i));
      } else
        cnt++;
    } else {
      if (q[4].size()) {
        q[4].pop();
      } else
        cnt++;
    }
  }
  int ans = 0;
  for (i = 0; i < 6; i++) {
    ans += int(q[i].size()) * (i + 1);
  }
  cout << ans + cnt;
  return 0;
}
