#include #include using namespace std; int main() { int n; cin >> n; vector v(n); for(int i = 0; i < n; i++) { cin >> v[i]; } int i = 0, j = 0; int cnt = 0; int result = 0; while(j < n) { if(cnt <= 3) { if(v[j] == 3) { cnt++; } j++; if(cnt == 3) { result = max(result, j - i); } } else { if(v[i] == 3) { cnt--; } i++; if(cnt == 3) { result = max(result, j - i); } } } cout << result << endl; return 0; }