#include #include typedef long long int llint; int main(void){ llint n; std::cin >> n; std::vector A(n); llint last = -1; llint count = 0; std::vector tunagari; for(int i=0; i> A[i]; if(i){ if(last != A[i]){ tunagari.push_back(count); count = 0; } } last = A[i]; count++; } if(count) tunagari.push_back(count); if(tunagari.size()%2) tunagari.push_back(0); std::vector dp(tunagari.size()+2); for(int i=tunagari.size()-1; i>=0; i--){ llint a = dp[i+2] + tunagari[i]; llint b = dp[i+1]; dp[i] = a