#include using namespace std; typedef long long ll; int dp[100100][2]; int main(){ int N; cin >> N; vector A(N); for(int i = 0; i < N; i++){ cin >> A[i];} dp[0][1] = 1; for(int i = 1; i < N; i++){ if(A[i-1] == A[i]){ dp[i][1] = max(dp[i-1][1]+1, dp[i-1][0]+1); dp[i][0] = max(dp[i-1][1], dp[i-1][0]); } else{ dp[i][1] = dp[i-1][0]+1; dp[i][0] = max(dp[i-1][1],dp[i-1][0]); } } cout << max(dp[N-1][0], dp[N-1][1]) << endl; return 0; }