#include "bits/stdc++.h" #define REP(i, n) for(int i = 0; i < int(n); i++) #define FOR(i,n,m) for(int i = int(n); i < int(m); i++) using namespace std; typedef long long ll; const int MOD = 1e9 + 7; const int INF = 1e9 + 6; const ll LLINF = 1e18 + 1; int main() { int n; cin >> n; vector a(n); REP(i, n) cin >> a[i]; // dp[i][j] : j(unused : used) vector> dp(n+1, vector(2, 0)); REP(i, n) { dp[i+1][0] = max(dp[i][0], dp[i][1]); if (i > 0 && a[i] == a[i - 1]) { dp[i+1][1] = dp[i][1] + 1; } dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + 1); } cout << max(dp[n][1], dp[n][0]) << endl; return 0; }