#define _USE_MATH_DEFINES #include using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector> dp(n, vector(2)); dp[0][1] = 1; for (int i = 1; i < n; i++) { dp[i][0] = max(dp[i - 1][1], dp[i - 1][0]); dp[i][1] = max(dp[i - 1][1] + (int) (a[i] == a[i - 1]), dp[i - 1][0] + 1); } cout << max(dp[n - 1][0], dp[n - 1][1]) << '\n'; return 0; }