#include <bits/stdc++.h>   using namespace std;   const int N = 100005, mod = 1000000007;   int n, m, T, q, f[6];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       for (int j = 1; j <= 4; j++) {         if ((j & 1) == (x & 1)) f[j]++;       }       for (int j = 2; j <= 4; j++) f[j] = max(f[j], f[j - 1]);     }     printf( %d n , f[4]);     return 0;   }   