#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
struct node {
int a[11451] = {0};
} b[11451];
int book[11451] = {0};
int n;
int sum = 1;
int ma = 0;
void dfs(int x) {
while (b[x].a[x + 1] == 0 && book[x + 1] == 0) {
book[x + 1] = 1;
x++;
sum++;
}
ma = max(sum, ma);
sum = 1;
return;
}
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
b[i].a[n] = 1;
}
int temp;
for (int i = 0; i < n; i++) {
cin >> temp;
if (temp == 3) {
for (int j = i + 1; j < n; j++) {
b[i].a[j] = 1;
b[j].a[i] = 1;
}
} else if (temp == 2) {
for (int j = 0; j < i; j++) {
b[i].a[j] = 1;
b[j].a[i] = 1;
}
}
}
for (int i = 0; i < n; i++) {
if (book[i] == 0 && b[i].a[i + 1] == 0) {
book[i] = 1;
dfs(i);
}
}
cout << ma;
return 0;
}