#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long inf = 1e18;
long long m_inf = INT_MIN;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  std::cout.unsetf(std::ios::fixed);
  std::cout.precision(9);
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> arr(n);
    for (long long i = 0; i < n; i++) cin >> arr[i];
    long long cnt[6] = {0};
    for (long long i = 0; i < n; i++) {
      if (arr[i] == 4) {
        cnt[0]++;
      } else if (arr[i] == 8) {
        if (cnt[0] > 0) {
          cnt[0]--;
          cnt[1]++;
        }
      } else if (arr[i] == 15) {
        if (cnt[1] > 0) {
          cnt[1]--;
          cnt[2]++;
        }
      } else if (arr[i] == 16) {
        if (cnt[2] > 0) {
          cnt[2]--;
          cnt[3]++;
        }
      } else if (arr[i] == 23) {
        if (cnt[3] > 0) {
          cnt[3]--;
          cnt[4]++;
        }
      } else if (arr[i] == 42) {
        if (cnt[4] > 0) {
          cnt[4]--;
          cnt[5]++;
        }
      }
    }
    cout << n - (6 * (cnt[5])) << '\n';
  }
}
