ll@L,@N,@X[N],b[L]={},x;rep(i,b[X[0]]=1,N)rrep(j,L-(x=X[i]-X[i-1]))b[j+x]|=b[j];wt(min[i,0,L@b[i]](abs(i*2-L)));