#include <bits/stdc++.h>
using namespace std;
template <class T, class... U>
void pr(T&& a, U&&... b) {
  cout << forward<T>(a);
  (int[]){(cout << forward<U>(b), 0)...};
}
template <class T, class... U>
void re(T&& a, U&&... b) {
  cin >> forward<T>(a);
  (int[]){(cin >> forward<U>(b), 0)...};
}
const int MAXN = 5e5;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int N, A[MAXN + 5];
int cnt1, cnt2, cnt3, cnt4, cnt5, cnt6;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  re(N);
  for (int i = 1; i <= N; i++) re(A[i]);
  for (int i = 1; i <= N; i++) switch (A[i]) {
      case 4:
        cnt1++;
        break;
      case 8:
        if (cnt1 > 0) cnt2++, cnt1--;
        break;
      case 15:
        if (cnt2 > 0) cnt3++, cnt2--;
        break;
      case 16:
        if (cnt3 > 0) cnt4++, cnt3--;
        break;
      case 23:
        if (cnt4 > 0) cnt5++, cnt4--;
        break;
      case 42:
        if (cnt5 > 0) cnt6++, cnt5--;
        break;
    }
  pr(N - 6 * cnt6);
}
