//#define _AOJ_ /*vvv> zzzzzI .---. zzuzuI .vgggg&,. +++++= dAC:|I .WbbWo JMM9^```?TMB` ..&gNNg,. gggggggJ, qgggggggg] (&&&&&&&&[ c+OA&J, (&&&&&&+J, .cJeAA&-. (&&&&&&&&x .&AA&=-. +++++= dTqk|I Xpbpbp JM#` (M#^ ?MMp MM| +TMN. JMF ' |yk ` dVY 7Vk, Vy XV cVf ?Y! JM V$ ` +++++= dcf:|I Xppppp dMN .MM+ .MM MM| MM] JMMMMMM+ |@tqkoh) ,y0 (V$ yyyyyyyV7 VV JMWyZWr TWVVVVW&, ++++++ d7qk|0 Xppppp ^HMN, _.db WMm, .MMF MM| ..MM` JMF . |yk .WV&. .XW' yy 4yn. jyn +. JM #S `++++` ?ZZZX= ?WWWW= -THMMMMH9^ (TMMMMM9! MMMMMMM"" JMMMMMMMME |UU. ?TUUUUY= UU. (UU- ^7TUUUV7! JUUUUUUUU 7TUNKO*/ #include "bits/stdc++.h" using namespace std; typedef long long lint; typedef long double ld; typedef string cs; typedef vector liv; //#define rep(i,n) for(int i=0;i=0;--i) #define _rrep2(i,n) for(lint i=n-1;i>=0;--i) #define _rrep3(i,a,b) for(lint i=b-1;i>=a;--i) #define _rrep4(i,a,b,c) for(lint i=a+(b-a-1)/c*c;i>=a;i-=c) template istream& operator>>(istream& is,vector& vec); template istream& operator>>(istream& is,array& vec); template istream& operator>>(istream& is,pair& p); template ostream& operator<<(ostream& os,vector& vec); template ostream& operator<<(ostream& os,pair& p); template istream& operator>>(istream& is,vector& vec){ for(T& x: vec) is>>x;return is; } template istream& operator>>(istream& is,pair& p){ is>>p.first;is>>p.second;return is; } template ostream& operator<<(ostream& os,pair& p){ os< inline void in(Head&& head,Tail&&... tail){ cin>>head;in(move(tail)...); } inline bool out(){ cout<<'\n';return 0; } template inline bool out(T t){ cout< inline bool out(Head head,Tail... tail){ cout< inline void ssize(lint s,Head&& head,Tail&&... tail){ head.resize(s);ssize(s,move(tail)...); } #define rep(...) _vcppunko4((__VA_ARGS__,_trep4,_trep3,_trep2,_rep1))((__VA_ARGS__)) #define rrep(...) _vcppunko4((__VA_ARGS__,_trrep4,_trrep3,_trrep2,_rrep1))((__VA_ARGS__)) template ostream& operator<<(ostream& os,vector& vec){ os< ostream& operator<<(ostream& os,deque& deq){ os< name(size);in(name) #define fi e.first #define se e.second #define YES(c) cout<<((c)?"YES\n":"NO\n"),0 #define Yes(c) cout<<((c)?"Yes\n":"No\n"),0 #define POSSIBLE(c) cout<<((c)?"POSSIBLE\n":"IMPOSSIBLE\n"),0 #define Possible(c) cout<<((c)?"Possible\n":"Impossible\n"),0 #define o(p) cout< md_tmp class mint{ using u64=uint_fast64_t; public: u64 a; constexpr mint(const u64 x=0) noexcept: a(x%md){} constexpr u64 &value() noexcept{ return a; } constexpr const u64 &value() const noexcept{ return a; } constexpr mint operator+(const mint rhs) const noexcept{ return mint(*this)+=rhs; } constexpr mint operator-(const mint rhs) const noexcept{ return mint(*this)-=rhs; } constexpr mint operator*(const mint rhs) const noexcept{ return mint(*this)*=rhs; } constexpr mint operator^(const lint rhs) const noexcept{ return mint(*this)^=rhs; } constexpr mint operator/(const mint rhs) const noexcept{ return mint(*this)/=rhs; } constexpr mint &operator+=(const mint rhs) noexcept{ a+=rhs.a; if(a>=md)a-=md; return *this; } constexpr mint &operator-=(const mint rhs) noexcept{ if(aa; while(exp){ if(exp&1)*this*=base; base*=base; exp>>=1; } return *this; } constexpr mint &operator/=(const mint rhs) noexcept{ a=(*this*(rhs^(md-2))).a; return *this; } }; md_tmp istream& operator>>(istream& os,mint& m){ os>>m.a,m.a%=md; return os; } md_tmp ostream& operator<<(ostream& os,const mint& m){ return os< ncr(lint n,lint r){ if(n(0); mintncr_res=1,ncr_div=1; rep(r)ncr_res*=(n-i),ncr_div*=(r-i); return ncr_res/ncr_div; } #ifndef _AOJ_ mint<> operator""m(unsigned long long n){ return mint<>(n); } mint<998244353> operator""m9(unsigned long long n){ return mint<998244353>(n); } mint<1000003> operator""m3(unsigned long long n){ return mint<1000003>(n); } #endif using mi=mint<>; ////P //class P{ public:lint f,s; constexpr P(lint a,lint b):f(a),s(b){};constexpr P():f(0),s(0){}; }; //istream& operator>>(istream& is,P& p){ is>>p.f>>p.s;return is; } //ostream& operator<<(ostream& os,const P& p){ return os<(const P& l,const P& r){ return(l.f-r.f?l.f>r.f:l.s>r.s); } struct C{ lint f,s,t; }; bool operator<(const C& l,const C& r){ return l.t(const C& l,const C& r){ return l.t>r.t; } //const #define linf 1152921504606846976 #define inf linf//INT_MAX #define MAXN 330 #define md_1e9_7 1000000007 #define md_998244353 998244353 #define pi 3.14159265358979323846 //#define mod md_1e9_7 const int d4[5]={0,1,0,-1,0}; //funcs #define compare(T,s) [](T l,T r){return(s);} inline void eraseunique(string &v){//nの変更を忘れるな v.erase(unique(all(v)),v.end()); } template vector> runlength(vector v){ lint n=v.size(); vector> ret(1,{v[0],1}); rep(n){ if(ret[ret.size()-1].first==v[i])++ret[ret.size()-1].second; else ret.push_back({v[i],1}); }--ret[0].second; return ret; } template//ラムダ式の受け取り方 vector ruiseki(vector a,F f,lint e){ lint n=a.size(); vector s(n+1); rep(n)s[i+1]=f(s[i],a[i]); return s; } set< lint > divisor(lint n){ set< lint > ret; for(lint i = 1; i * i <= n; i++){ if(n % i == 0){ ret.insert(i); if(i * i != n) ret.insert(n / i); } } return (ret); } //\funcs lint dp[100010]; int main(){ lin(n); vectora(n);in(a); auto b=runlength(a); lint m=b.size(); dp[0]=b[0].second;dp[1]=b[1].second; rep(n){ dp[i+1]=max(dp[i+1],dp[i]); if(i+2