#include #include #include #include #include #include #include using namespace std; #define int long long #define endl "\n" const long long INF = (long long)1e18; const long long MOD = 1'000'000'007; string yn(bool f){return f?"Yes":"No";} string YN(bool f){return f?"YES":"NO";} signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout< A, used; vector> B; static int dp[MAX] = {}; priority_queue> Q; cin>>N; A.resize(N); used.resize(N+10); for(int i = 0; i < N; i++){ cin>>A[i]; if(B.size() == 0) B.push_back({1,A[i]}); else if(B.back().second == A[i]) B.back().first++; else B.push_back({1,A[i]}); } // for(int i = 0; i < B.size(); i++){ //cout< P = Q.top(); Q.pop(); // int con = P.second; // if(used[con]) continue; // used[con+1] = true; // used[con] = true; // used[con-1] = true; // a += P.first; // } for(int i = 0; i < B.size(); i++){ dp[i+2] = max(dp[i+2], B[i].first+dp[i]); dp[i+1] = max(dp[i+1], dp[i]); a = max(dp[i], dp[i+1]); a = max(dp[i], dp[i+2]); } cout<