#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int N = 3000010;
int a[N], num[N];
int main() {
  int n;
  scanf("%d", &n);
  int id = 0;
  memset(num, 0, sizeof(num));
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    if (a[i] == 4) {
      id = 0;
    } else if (a[i] == 8) {
      id = 1;
    } else if (a[i] == 15)
      id = 2;
    else if (a[i] == 16)
      id = 3;
    else if (a[i] == 23)
      id = 4;
    else if (a[i] == 42)
      id = 5;
    if (id > 0 && num[id] >= num[id - 1]) {
      ++ans;
    } else {
      num[id]++;
    }
  }
  for (int i = 5; i > 0; --i) {
    if (num[i] != num[i - 1]) {
      ans += (num[i - 1] - num[i]);
      num[i - 1] = num[i];
    }
  }
  cout << ans << endl;
}
