#include<iostream>
using namespace std;
int n,w,a[1001],s=0;
int d[10101]={0};
int used [1010]={0};
void f (int p)
{
  for (int j=0; j<n; j++)
  {
    if (used[j]==0) {used[j]=1; s=s+a[j]; d[s]=1; f(j);}
  }
  s=s-a[p];
  used[p]=0;
  return ;
}
int main ()
{
cin>>n>>w;
for (int i=0; i<n; i++)
{
  cin>>a[i];
}
for (int i=0; i<n; i++)
{
 s=0;
 used[i]=1;
  d[a[i]]=1;
  s=a[i];
 f(i);
}
for (int i=w; i>=0; i--)
{
    if (d[i]==1) {cout<<i<<endl; break;}
}
return 0;
}
