#include #include using namespace std; #define MAXN 1000 typedef long long LL; int n,c[MAXN+10],l[MAXN+10],r[MAXN+10],T,a[MAXN+10]; long long mod[MAXN+10],b[MAXN+10]; template void Read(T &x){ char c; while(c=getchar(),c!=EOF) if(c>='0'&&c<='9'){ x=c-'0'; while(c=getchar(),c>='0'&&c<='9') x=x*10+c-'0'; ungetc(c,stdin); return; } } void read(){ Read(n); int i,now=0; for(i=1;i<=n;i++){ Read(b[i]); a[b[i]]=i; } for(int j=2;j<=n;j++) l[j]=j-1; l[1]=n; for(int j=1;j