#include using namespace std; using ll =long long; #define all(v) v.begin(),v.end() #define rep(i,a,b) for(int i=a;i=b;i--) int main() { ll N;cin>>N; vector P(N); vector note(N,0); for(ll i=0;i>P[i]; note[P[i]-1]=i+1; } vector r(N+1); r[0]=0; for(ll i=0;i0;i--) { ans=max(ans,r[i-1]-note[i-1]); } cout<