#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a>n>>m; vector w(n); for(Int i=0;i>w[i]; const Int INF = 1e12; for(Int a=0;a<2;a++) for(Int b=0;b<2;b++) for(Int i=0;i<3030;i++) for(Int j=0;j<3030;j++) dp[a][b][i][j]=-INF; dp[0][0][1][0]=0; dp[1][1][1][1]=0; for(Int i=1;i