#include <bits/stdc++.h>
using namespace std;
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  };
  int n;
  cin >> n;
  if (n < 6) {
    cout << n;
    return 0;
  }
  int arr[6] = {0};
  for (int i = 0; i < n; i++) {
    int ct;
    cin >> ct;
    if (ct == 4)
      arr[0] += 1;
    else if (ct == 8) {
      arr[1] += 1;
      arr[1] = min(arr[0], arr[1]);
    } else if (ct == 15) {
      arr[2] += 1;
      arr[2] = min(arr[2], arr[1]);
    } else if (ct == 16) {
      arr[3] += 1;
      arr[3] = min(arr[2], arr[3]);
    } else if (ct == 23) {
      arr[4] += 1;
      arr[4] = min(arr[3], arr[4]);
    } else if (ct == 42) {
      arr[5] += 1;
      arr[5] = min(arr[4], arr[5]);
    }
  }
  cout << n - arr[5] * 6;
  return 0;
}
