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

ll solve(vector<ll> &A1, vector<ll> &A2, ll &T) {
  bitset<20> bs;
  vector<ll> B;
  ll res=0;
  for(ll i=0; i<pow(2,A1.size()); ++i) {
    ll count=0; bs=i;
    for(ll j=0; j<A1.size(); ++j) if(bs.test(j)) count+=A1[j];
    B.push_back(count);
  }
  sort(B.begin(),B.end());
  for(ll i=0; i<pow(2,A2.size()); ++i) {
    ll count=0; bs=i;
    for(ll j=0; j<A2.size(); ++j) if(bs.test(j)) count+=A2[j];
    if(count<=T) {
      count+=*(upper_bound(B.begin(),B.end(),T-count)-1);
      res=max(res,count);
    }
  }
  return res;
}

int main() {
  ll N,T; cin>>N>>T;
  vector<ll> A1, A2;
  for(ll i=0; i<N; ++i) {
    ll A; cin>>A;
    if(i<N/2) A1.push_back(A);
    else A2.push_back(A);
  }
  cout << solve(A1,A2,T) << endl;
}

#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define forn(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define ford(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define int long long
#define ii pair<int,int>
#define ar array
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define sz(x) ((int)(x).size())
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;
//const int N = 3e5+7 ;
/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
//debug
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void solve(){
    int n , t ;
    cin >> n >> t ;
    vector<int> a(n) ;
    for(auto& x : a) cin >> x ;
    vector<int> s1{0} , s2{0} ;
    forn(i,n) {
        int m = sz(s1) ;
        forn(j,m) s1.push_back(s1[j]+a[i]) ;
        swap(s1,s2) ;  
    }
    sort(all(s1)) ;
    reverse(all(s1)) ;
    int ans = 0 ;
    forn(i,sz(s2)) {
        if(s2[i] > t) continue ;
        ans = max(ans , s2[i]+ *lb(all(s1),t-s2[i],greater<int>())) ;
    }
    cout << ans << endl ;
}


int32_t main(){
    FAST_IO ;
    int t = 1 ;
//    cin >> t ;
    while(t--){
        solve() ;
    }
}
