#include #include using namespace std; int N; int s[2][1000][1001]; main() { cin>>N; for(int i=0;i>A;A--; s[1][A][0]+=j; if(js[1][A][i])now=s[1][A][i]; s[0][A][i+1]+=s[0][A][i]; s[1][A][i+1]+=s[1][A][i]; } ans+=now; } cout<