//bribe the prisoners
//http://blog.csdn.net/lizo_is_me/article/details/43735509
//compute the sub item first , then left_cost+right_cost+item(i->j)-1 =>cost of bribe i->j
//dp+iterate
//http://blog.csdn.net/lizo_is_me/article/details/43735509
//compute the sub item first , then left_cost+right_cost+item(i->j)-1 =>cost of bribe i->j
//dp+iterate
//bribe the prisoners
//http://blog.csdn.net/lizo_is_me/article/details/43735509
//compute the sub item first , then left_cost+right_cost+item(i->j)-1 =>cost of bribe i->j
//dp+iterate
#include<iostream>
#define inf 0x7fffffff
using namespace std;
int a[maxn+10],cost[maxn+10][maxn+10];
void solve(){
a[0]=0,a[n+1]=n+1;
for(int i=0;i<n+1;i++){
cost[i][i+1]=0;
}
for(int w=2;w<=n+1;w++){
for(int i=0;i+w<=n+1;i++){
int j=i+w,temp=inf;
for(int k=i+1;k<j;k++){
temp=min(temp,cost[i][k]+cost[k][j]);
}
cost[i][j]=temp+a[j]-a[i]-1-1; //first for a[j]-a[i]-1(not include border),the other for minus itself
}
}
cout<<cost[0][n+1];
}