#include using namespace std; using lint = long long; template using V = vector; template using VV = V< V >; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; V<> a(n); for (auto&& e : a) cin >> e; V<> dp(2); dp[1] = 1; for (int i = 1; i < n; ++i) { V<> ndp(2); ndp[0] = max(dp[0], dp[1]); if (a[i - 1] == a[i]) { ndp[1] = dp[1] + 1; } else { ndp[1] = dp[0] + 1; } swap(dp, ndp); } cout << max(dp[0], dp[1]) << '\n'; }