#include using namespace std; int main(){ int n; cin >> n; vector a(n); for(int i = 0;i < n;i++){ cin >> a[i]; } vector> pa; pa.push_back({a[0], 1}); int size = 1; for(int i = 1;i < n;i++){ if(pa[size-1].first == a[i]){ pa[size-1].second++; }else{ pa.push_back({a[i], 1}); size++; } } int dp[100010]; dp[0] = pa[0].second; if(1 < size){ dp[1] = max(dp[0], pa[1].second+dp[0]-1); for(int i = 2;i < size;i++){ dp[i] = max(dp[i-1]-1+pa[i].second, dp[i-2]+pa[i].second); } } cout << dp[size-1] << endl; return 0; }