#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const int N = 5e5 + 5;
const int mod = 1e9 + 7;
const int Mx = 1e7;
vector<int> pos[N];
int a[6] = {4, 8, 15, 16, 23, 42};
int New[100];
int vis[N];
void solve() {
  int n;
  cin >> n;
  int x;
  for (int i = 0; i < 50; i++) pos[i].clear();
  for (int i = 0; i < n; i++) {
    cin >> x;
    pos[x].push_back(i);
  }
  int Mi = inf;
  for (int i = 0; i < 6; i++) {
    Mi = min(int(pos[a[i]].size()), Mi);
  }
  for (int i = 0; i < 6; i++) {
    pos[a[i]].push_back(-1);
  }
  int cnt;
  bool f = true;
  for (cnt = 0; cnt <= Mi; cnt++) {
    int last = -1;
    for (int i = 0; i < 6; i++) {
      for (int j = New[a[i]]; j < pos[a[i]].size(); j++) {
        int tmp = pos[a[i]][j];
        if (tmp == -1) {
          f = false;
          break;
        }
        if (vis[tmp])
          continue;
        else {
          if (last < tmp) {
            vis[tmp] = true;
            last = tmp;
            New[a[i]] = j + 1;
            break;
          } else
            continue;
        }
      }
      if (!f) break;
    }
    if (!f) break;
  }
  cout << n - cnt * 6 << endl;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
