#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
int n, t, x, y, m, tmp, sum, ans, b[50];
int a[N], dp[10];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  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 >> a[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == 4) {
      dp[0]++;
    } else {
      if (dp[b[a[i]] - 1] > 0) {
        dp[b[a[i]] - 1]--;
        dp[b[a[i]]]++;
      } else {
        ans++;
      }
    }
  }
  for (int i = 0; i < 5; i++) {
    if (dp[i] > 0) {
      ans += dp[i] * (i + 1);
    }
  }
  cout << ans;
  return 0;
}
