#include <bits/stdc++.h>
using namespace std;
unordered_map<string, int> ans;
void solve() {
  stack<int> c4, c8, c15, c16, c23, c42;
  int count = 0;
  int n;
  cin >> n;
  for (int i = 0; i <= n - 1; i += 1) {
    int k;
    cin >> k;
    if (k == 4) {
      c4.push(k);
    } else if (k == 8) {
      if (c4.size() > c8.size()) {
        c8.push(k);
      } else {
        count++;
      }
    } else if (k == 15) {
      if (c8.size() > c15.size()) {
        c15.push(k);
      } else {
        count++;
      }
    } else if (k == 16) {
      if (c15.size() > c16.size()) {
        c16.push(k);
      } else {
        count++;
      }
    } else if (k == 23) {
      if (c16.size() > c23.size()) {
        c23.push(k);
      } else {
        count++;
      }
    } else {
      if (c23.size() > c42.size()) {
        c42.push(k);
      } else {
        count++;
      }
    }
  }
  if (c42.size() == 0) {
    cout << n;
    return;
  } else {
    cout << n - (6 * c42.size());
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n = 1;
  for (int i = 0; i < n; i++) {
    solve();
  }
}
