#include using namespace std; using ll = long long; using ld = long double; const ld pi = 3.14159265358979; const int mod = 1000000007; int main(){ int n; cin >> n; vector a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } vector> dp(n + 10 , vector(2 , 0)); dp[0][0] = 0; dp[0][1] = 1; for(int i = 1; i < n; i++){ if(a[i] != a[i - 1]){ dp[i][0] = max(dp[i - 1][1] , dp[i - 1][0]); dp[i][1] = dp[i - 1][0] + 1; }else{ dp[i][1] = max(dp[i - 1][1] + 1 , dp[i - 1][0] + 1); dp[i][0] = max(dp[i - 1][0] , dp[i - 1][1]); } } cout << max(dp[n - 1][0] , dp[n - 1][1]) << endl; return 0; }