#include #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; typedef pair pll; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector a(n); rep(i, n) cin >> a[i]; ll dp[n][2]; rep(i, n+1) rep(j, 2) dp[i][j] = 0; dp[0][1] = 1; rep(i, n - 1){ if(a[i+1] == a[i]){ dp[i+1][0] = max(dp[i][0], dp[i][1]); dp[i+1][1] = max(dp[i][0], dp[i][1]) + 1; }else{ dp[i+1][0] = max(dp[i][0], dp[i][1]); dp[i+1][1] = dp[i][0] + 1; } } cout << max(dp[n-1][0], dp[n-1][1]) << endl; }