#include <bits/stdc++.h>
using namespace std;
int n, arr[15], x, ans;
int main() {
  scanf("%d", &n);
  if (n < 6)
    printf("%d\n", n);
  else {
    for (int i = 0; i < n; i++) {
      scanf("%d", &x);
      if (x == 4)
        arr[1]++;
      else if (x == 8) {
        if (arr[1] < arr[2] + 1)
          ans++;
        else
          arr[2]++;
      } else if (x == 15) {
        if (arr[2] < arr[3] + 1)
          ans++;
        else
          arr[3]++;
      } else if (x == 16) {
        if (arr[3] < arr[4] + 1)
          ans++;
        else
          arr[4]++;
      } else if (x == 23) {
        if (arr[4] < arr[5] + 1)
          ans++;
        else
          arr[5]++;
      } else if (x == 42) {
        if (arr[5] < arr[6] + 1)
          ans++;
        else
          arr[6]++;
      } else
        ans++;
    }
    for (int i = 1; i < 7; i++) {
      ans += arr[i] - arr[6];
    }
    printf("%d\n", ans);
  }
}
