#include int ri() { int n; scanf("%d", &n); return n; } int main() { int n = ri(); int a[n + 1]; for (int i = 0; i < n; i++) a[i] = ri(); int dp[n + 1]; memset(dp, 0, sizeof(dp)); for (int i = 0; i < n; i++) { dp[i + 1] = std::max(dp[i + 1], dp[i]); if (a[i] != a[i + 1]) dp[std::min(i + 2, n)] = std::max(dp[std::min(i + 2, n)], dp[i] + 1); else dp[i + 1] = std::max(dp[i + 1], dp[i] + 1); } std::cout << dp[n] << std::endl; return 0; }