#include using std::cin; using std::cout; using std::endl; using std::vector; using ll=long long; const int mod=1e9+7; int main(){ int N; cin>>N; vector A(N); for(int i=0;i>A[i]; { vector B=A; sort(B.begin(),B.end()); if(B[N-1]==1){ cout<=2*N) break; } if(ans>=2*N){ ans=1; for(int i=0;i1) break; ans++; } for(int i=N-1;i>=0;i--){ if(A[i]>1) break; ans++; } ans%=mod; cout<=0;i--){ if(A[i]>1) break; ans++; A.pop_back(); } reverse(A.begin(),A.end()); for(int i=A.size()-1;i>=0;i--){ if(A[i]>1) break; ans++; A.pop_back(); } vector comp(1,A[0]); for(int i=1;i1){ if(A[i-1]>1) comp[comp.size()-1]*=A[i]; else comp.push_back(A[i]); } else{ if(A[i-1]>1) comp.push_back(1); else comp[comp.size()-1]++; } } int M=comp.size(); ll max=0; for(int i=0;i<(1<