#include <bits/stdc++.h>
int mod = 1e9 + 7;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, temp;
  cin >> n;
  int ar[6] = {0};
  for (int i = 0; i < n; i++) {
    cin >> temp;
    if (temp == 4)
      ar[0]++;
    else if (temp == 8) {
      if (ar[1] != ar[0]) ++ar[1];
    } else if (temp == 15) {
      if (ar[2] != ar[1]) ++ar[2];
    } else if (temp == 16) {
      if (ar[3] != ar[2]) ++ar[3];
    } else if (temp == 23) {
      if (ar[4] != ar[3]) ++ar[4];
    } else {
      if (ar[5] != ar[4]) ++ar[5];
    }
  }
  int m = INT_MAX;
  for (int i = 0; i < 6; i++) m = min(m, ar[i]);
  cout << n - m * 6;
}
