#include <bits/stdc++.h>
int n, x, t4, t8, t15, t16, t23, t42;
int lose;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    if (x == 4) {
      t4++;
    } else if (x == 8) {
      if (t4 > t8) t8++;
    } else if (x == 15) {
      if (t8 > t15) t15++;
    } else if (x == 16) {
      if (t15 > t16) t16++;
    } else if (x == 23) {
      if (t16 > t23) t23++;
    } else if (x == 42) {
      if (t23 > t42) t42++;
    }
  }
  printf("%d", n - t42 * 6);
}
