#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x>N; FOR(i,N+1) cin>>S[i]; memset(dp,0x3f,sizeof(dp)); dp[0][0]=1; for(i=0;i<=N;i++) { FOR(j,S[i]+1) { if(i) dp[i][j]=dp[i-1][j]+1; for(x=0;x