#include #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; template vector> run_length_encoding(const vector& a){ vector> res; int n=a.size(),pre=0; rep(i,n) if(i==n-1 || a[i]!=a[i+1]) res.emplace_back(a[i],i-pre+1), pre=i+1; return res; } int main(){ int n; scanf("%d",&n); vector a(n); rep(i,n) scanf("%d",&a[i]); auto rle=run_length_encoding(a); int m=rle.size(); vector dp(m+1); dp[1]=rle[0].second; for(int i=1;i