#include #include #include #include using namespace std; using i64 = long long; #define rep(i,n) for(int i=0; i<(int)(n); i++) int N; int P[3000]; int I[3001][3001]; int dp[3001] = {}; int ans[3001] = {}; int main(){ int N; cin >> N; rep(i,N){ cin >> P[i]; P[i]--; } rep(i,N) rep(j,i) if(P[j] > P[i]) I[j][i+1]++; rep(r,N+1) for(int l=r-1; l>=0; l--) I[l][r] += I[l+1][r]; rep(r,N+1) for(int l=r-1; l>=0; l--) I[l][r] += I[l][r-1]; int dp = 0; set A; A.insert(0); A.insert(N); cout << "0\n"; rep(i,N-1){ pair p = { 1001001001, 0 }; for(int m=1; m