#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  long long arr[n];
  long long freq[6] = {};
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] == 4)
      freq[0]++;
    else if (arr[i] == 8 && freq[0] >= (freq[1] + 1))
      freq[1]++;
    else if (arr[i] == 15 && freq[0] >= (freq[2] + 1) &&
             freq[1] >= (freq[2] + 1))
      freq[2]++;
    else if (arr[i] == 16 && freq[0] >= (freq[3] + 1) &&
             freq[1] >= (freq[3] + 1) && freq[2] >= (freq[3] + 1))
      freq[3]++;
    else if (arr[i] == 23 && freq[0] >= (freq[4] + 1) &&
             freq[1] >= (freq[4] + 1) && freq[2] >= (freq[4] + 1) &&
             freq[3] >= (freq[4] + 1))
      freq[4]++;
    else if (arr[i] == 42 && freq[0] >= (freq[5] + 1) &&
             freq[1] >= (freq[5] + 1) && freq[2] >= (freq[5] + 1) &&
             freq[3] >= (freq[5] + 1) && freq[4] >= (freq[5] + 1))
      freq[5]++;
  }
  long long f = INT_MAX;
  for (long long i = 0; i < 6; i++) {
    f = min(freq[i], f);
  }
  cout << n - 6 * f << endl;
}
