#include #include #include using namespace std; const int maxn=60; int n,f[maxn][maxn][2600],b[maxn],c[maxn]; int dp(int i,int j,int k) { int &res=f[i][j][k]; if(res) return res; if(i==j) return res=(c[i]+k)*(c[i]+k); res=dp(i,j-1,0)+(k+c[j])*(k+c[j]); for(int p=i;p