#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     a = abs(a), b = abs(b);     if (a < b) swap(a, b);     return b ? gcd(b, a % b) : a;   }   vector<vector<int> > adj;   set<int> st;   const int dx[] = {0, 0, -1, 1};   const int dy[] = {-1, 1, 0, 0};   long long n, ary[300000 + 5] = {4, 8, 15, 16, 23, 42}, dp[300000 + 5];   int main(void) {     ios::sync_with_stdio(false), cin.tie(NULL);     cin >> n;     for (int i = 0, j, x; i < n; ++i) {       cin >> x;       j = lower_bound(ary, ary + 6, x) - ary;       if (j == 0)         dp[0] += 1;       else if (dp[j - 1]) {         dp[j - 1] -= 1;         dp[j] += 1;       }     }     cout << n - dp[5] * 6;     return 0;   }   