/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

// clang-format off
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep2(i, a, b) for (int i = (int)(a), i##_len=(b); i < i##_len; i++)
#define rep3(i, a, b) for (int i = (int)(a), i##_len=(b); i >= i##_len; i--)
#define FOR(i, a) for (auto &i: a)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

const int MOD    = 998244353;
const int MOD2   = 1000000007;
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = 3.14159265358979;
template <class T> using V = vector<T>;
template <class T> using VV = vector<vector<T>>;
template <class T, class S>  using P = pair<T, S>;
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b;return true;}return false;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b;return true;}return false;}
int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int &a) {a = a >= 0 ? a % MOD : a - (MOD * CEIL(a, MOD));return a;}
int POW(int a, int b) {int res = 1;for (a %= MOD; b; a = a * a % MOD, b >>= 1)if (b & 1) res = res * a % MOD;return res;}
// clang-format on

template <class T> inline int Lower_bound_reverse(vector<T> &A, T key) { //key以下の最大のindex, 存在しない場合-1を返す。
  int ind = UPPER_BOUND(A, key) - 1;
  if (0 <= ind and ind < (int)A.size()) return ind;
  return -1;
}

class FProgrammingContest {
public:
  static void solve(istream &cin, ostream &cout) {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int N, T;
    cin >> N >> T;
    V<int> A(N / 2);
    V<int> B(CEIL(N, 2));
    rep(i, N / 2) cin >> A[i];
    rep(i, CEIL(N, 2)) cin >> B[i];
    vector<int> a = {0};
    vector<int> b = {0};
    vector<int> temp;
    FOR(i, A) {
      temp = {};
      FOR(j, a)
      if (i + j <= T)
        temp.emplace_back(i + j);
      FOR(j, temp)
      a.emplace_back(j);
    }
    FOR(i, B) {
      temp = {};
      FOR(j, b)
      if (i + j <= T) temp.emplace_back(i + j);
      FOR(j, temp)
      b.emplace_back(j);
    }
    sort(ALL(b));
    int ans = 0;
    FOR(i, a) {
      int ind = Lower_bound_reverse(b, T - i);
      if (0 <= ind and ind <= b.size()) chmax(ans, i + b[ind]);
    }
    cout << ans << endl;
  }
};


signed main() {
  FProgrammingContest solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N >> T;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	set<long long int>st;
	for (int i = 0; i < 1<<(N / 2); i++) {
		long long int sum = 0;
		for (int j = 0; j < N / 2; j++) {
			if (i >> j & 1)sum += v[j];
		}
		st.insert(sum);
	}
	long long int ans = 0;
	for (int i = 0; i < 1 << (N - N / 2); i++) {
		long long int sum = 0;
		for (int j = 0; j < N - N / 2; j++) {
			if (i >> j & 1) {
				sum += v[j + N / 2];
			}
		}
		auto it = st.upper_bound(T - sum);
		if (it != st.begin()) {
			ans = max(ans, sum + *prev(it));
		}
	}
	cout << ans << endl;
}