#include #include #include #define llint long long using namespace std; llint n; string s; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; llint ans = 0; char c; for(int i = 0; i < n; i++){ cin >> c; if(c == '3' || c == '5' || c == '7') ans++; else s += c; } llint cnt1 = 0, cnt9 = 0; for(int i = 0; i < s.size(); i++){ if(s[i] == '1') cnt1++; else{ if(cnt1) ans++, cnt1--; else cnt9++; } } ans += cnt1/2, cnt1%=2; if(cnt9 >= 2 && cnt1 >= 1) ans++; cout << ans << endl; return 0; }