#include <bits/stdc++.h>
using namespace std;
vector<int> a[6];
pair<int, int> level[6];
int main() {
  pair<int, int> level[6];
  int b[43];
  int n, x;
  cin >> n;
  b[4] = 0, b[8] = 1, b[15] = 2, b[16] = 3, b[23] = 4, b[42] = 5;
  for (int i = 0; i < n; i++) {
    cin >> x;
    a[b[x]].push_back(i);
  }
  for (int i = 0; i < 6; i++) level[i].first = 0, level[i].second = a[i].size();
  int count = 0, i, j, k;
  for (i = 0; i < level[0].second; i++) {
    level[0].first++;
    for (j = 0; j < 5; j++) {
      k = level[j + 1].first;
      while (k < level[j + 1].second && a[j + 1][k] < a[j][level[j].first - 1])
        k++;
      level[j + 1].first = k + 1;
      if (k >= level[j + 1].second) break;
    }
    if (j != 5)
      break;
    else
      count++;
  }
  cout << n - count * 6;
  return 0;
}
