#include using namespace std;#define N 102map f[N];int n,T,least,a[N];bool flag;void dp(int p,int val){ if(p==n+1){ least=min(least,abs(val-T)); return ; } if(val-T>=least) return; if(f[p][val]) return; f[p][val]=1; least=min(least,abs(val-T)); dp(p+1,val); dp(p+1,val+a[p]);}int main(){ scanf("%d%d",&n,&T); for(int i=1;i<=n;i++) scanf("%d",a+i); least=0x7fffffff; dp(1,0); for(int i=1;i<=n;i++) if(!a[i]){flag=1;break;} if(!T&&!least) printf("%d\n",flag?0:1); else printf("%d\n",least); return 0;}