#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n, t, m, res = 0;
    cin >> n >> t;
    vector<ll> a, b;
    for (int i = 0; i < n; i++) {
        ll x; cin >> x;
        if (i & 1) {
            b.push_back(x);
        } else {
            a.push_back(x);
        }
    }
    n = a.size(), m = b.size();
    vector<ll> va, vb;
    for (int i = 1; i < (1 << n); i++) {
        ll sum = 0;
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) {
                sum += a[j];
            }
        }
        va.push_back(sum);
    }
    for (int i = 1; i < (1 << m); i++) {
        ll sum = 0;
        for (int j = 0; j < m; j++) {
            if (i & (1 << j)) {
                sum += b[j];
            }
        }
        vb.push_back(sum);
    }
    sort(vb.begin(), vb.end());
    for (auto i : va) {
        if (i <= t) res = max(res, i);
        int j = upper_bound(vb.begin(), vb.end(), t - i) - vb.begin();
        if (j > 0) {
            res = max(res, i + vb[j - 1]);
        }
    }
    for (auto i : vb) {
        if (i <= t) {
            res = max(res, i);
        }
    }
    cout << res;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll  long long 
const ll INF = 10e7+7;
#define rep(i,n) for(int i=0;i<n;i++)
const double pi = acos(-1);
const ll MOD = 1000000007; 
ll cnt =0,ans=0;
typedef pair<int , int > P;
//cout << setprecision(11) << fixed;
const int di[] = {0,0,-1,1};
const int dj[] = {1,-1,0,0};


int main(){
  int N,T;  cin >> N >> T ;

  vector<int> a(N);
  rep(i,N) cin >> a[i];

  vector<ll>s,t;
  s = t = {0};

  for(int i=0;i<N;i++){
    for(int j = s.size()-1;j>=0;j--){
      s.push_back(s[j]+a[i]);
    }
    swap(s,t);
  }

  sort(s.begin(),s.end());

  for(auto x : t){
    if(x>T)continue;
    ll si = upper_bound(s.begin(),s.end(),T-x) - s.begin();
    ans=max(ans,x+s[si-1]); 
  }
  cout << ans << endl;
}