#include #define rep(i,n) for(int i=0;i P; const ll INF = 1e18; const int MOD = 1000000007; int main(){ int n; cin >> n; vector a(n); rep(i,n) cin >> a[i]; vector> dp(n,vector(2,0)); rep(i,n){ if(i==0){ dp[i][0] = 1; dp[i][1] = 0; }else{ if(a[i] == a[i-1]){ dp[i][0] = max(dp[i-1][0] + 1,dp[i-1][1] + 1); dp[i][1] = max(dp[i-1][0],dp[i-1][1]); }else{ dp[i][0] = dp[i-1][1] + 1; dp[i][1] = max(dp[i-1][0],dp[i-1][1]); } } } cout << max(dp[n-1][0],dp[n-1][1]) << endl; return 0; }