#include <bits/stdc++.h>
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
void solve() {
  int n;
  cin >> n;
  int a[n];
  int cnt = n % 6;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int cnt1 = 0;
  int cnt2 = 0;
  int cnt3 = 0;
  int cnt4 = 0;
  int cnt5 = 0;
  int cnt6 = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 4) {
      cnt1++;
    } else if (a[i] == 8 && cnt1) {
      cnt2++;
      cnt1--;
    } else if (a[i] == 15 && cnt2) {
      cnt3++;
      cnt2--;
    } else if (a[i] == 16 && cnt3) {
      cnt4++;
      cnt3--;
    } else if (a[i] == 23 && cnt4) {
      cnt5++;
      cnt4--;
    } else if (a[i] == 42 && cnt5) {
      cnt6++;
      cnt5--;
    }
  }
  cout << n - cnt6 * 6;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
