#include<iostream>
#include<algorithm>
using namespace std;
#define INF 10000000
int dp[25][30],n,h,f,s,a[25],ans,cnt=1,k,i,j;
int main()
{
// while(1)
//{
//cin>>n;
n=4;
for(int i=0;i<=n;i++)
for(int j=0;j<=n;j++)
if(j>i)dp[i][j]=-INF;
else
dp[i][j]=INF;
//if(n==0)
// break;
//for(int i=1;i<=n;i++)
// cin>>a[i];
a[1]=1;
a[2]=2;
a[3]=6;
a[4]=10;
//for( i=1;i<=n;i++) dp[i][1]=0;
for( i=2;i<=n;i++)
{
cout<<"i = "<<i<<"\n";
int o=-2*INF;
for( j=2;j<=i;j++)
{
cout<<"j = "<<j<<"\n";
for(k=1;k<i;k++)
{
if(k>=j-1)
o= max(o,min(dp[k][j-1],a[i]-a[k]));
//cout<<o<<"\n";
}
dp[i][j]=o;
}
}
for(i=1;i<=n;i++)
{
cout<<"\n";
for(j=1;j<=n;j++)
cout<<dp[i][j]<<" ";
}
//}
cout<<"cgfdshjfckldsgb";
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPGFsZ29yaXRobT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBJTkYgMTAwMDAwMDAKCmludCBkcFsyNV1bMzBdLG4saCxmLHMsYVsyNV0sYW5zLGNudD0xLGssaSxqOwoKaW50IG1haW4oKQp7CiAgIC8vIHdoaWxlKDEpCiAgICAvL3sKICAgICAgICAvL2Npbj4+bjsKCQluPTQ7CgogICAgICAgIGZvcihpbnQgaT0wO2k8PW47aSsrKQogICAgICAgICAgICBmb3IoaW50IGo9MDtqPD1uO2orKykKICAgICAgICAgICAgIGlmKGo+aSlkcFtpXVtqXT0tSU5GOwogICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgZHBbaV1bal09SU5GOwoKICAgICAgICAvL2lmKG49PTApCiAgICAgICAgICAvLyAgYnJlYWs7CgogICAgICAgIC8vZm9yKGludCBpPTE7aTw9bjtpKyspCiAgICAgICAgICAgLy8gY2luPj5hW2ldOwogICAgICAgICAgICBhWzFdPTE7CiAgICAgICAgICAgIGFbMl09MjsKICAgICAgICAgICAgYVszXT02OwogICAgICAgICAgICBhWzRdPTEwOwogICAgICAgIC8vZm9yKCBpPTE7aTw9bjtpKyspIGRwW2ldWzFdPTA7CgogICAgICAgIGZvciggaT0yO2k8PW47aSsrKQogICAgICAgIHsKICAgICAgICAJY291dDw8ImkgPSAiPDxpPDwiXG4iOwogICAgICAgIAlpbnQgbz0tMipJTkY7CiAgICAgICAgICAgIGZvciggaj0yO2o8PWk7aisrKQogICAgICAgICAgICB7CiAgICAgICAgICAgIAljb3V0PDwiaiA9ICI8PGo8PCJcbiI7CiAgICAgICAgICAgICAgICBmb3Ioaz0xO2s8aTtrKyspCgkJCQl7CgkJCQkJaWYoaz49ai0xKQoJCQkJCW89IG1heChvLG1pbihkcFtrXVtqLTFdLGFbaV0tYVtrXSkpOwogICAgICAgICAgICAgICAgICAgIC8vY291dDw8bzw8IlxuIjsKICAgICAgICAgICAgICAgIH0KCgkJCQlkcFtpXVtqXT1vOwogICAgICAgICAgICB9CiAgICAgICAgfQoKCQlmb3IoaT0xO2k8PW47aSsrKQoJCXsKCQkJY291dDw8IlxuIjsKCQkJZm9yKGo9MTtqPD1uO2orKykKCQkJY291dDw8ZHBbaV1bal08PCIgIjsKCQl9CgogICAgLy99CiAgICBjb3V0PDwiY2dmZHNoamZja2xkc2diIjsKfQoKCg==