#include using namespace std; // using namespace __gnu_pbds; // #include // using Bint = boost::multiprecision::cpp_int; // #include // using namespace atcoder; // https://atcoder.github.io/ac-library/production/document_ja/ typedef long long int ll; typedef long double ld; constexpr ll mod = 1e9+7; constexpr ll INF = 9'223'372'036'854'775'807/10; #define rep(i,n) for (ll i = 0; i < ll(n); ++i) #define Rep(i,a,n) for (ll i = (a); i < ll(n); ++i) #define All(a) (a).begin(),(a).end() #define Pi acos(-1) using V = vector; using P = pair; vector dx = {1, 0, -1, 0, 1, 1, -1, -1}; vector dy = {0, 1, 0, -1, 1, -1, 1, -1}; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b>; struct IoSetup { IoSetup() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << setprecision(15) << fixed; } } iosetup; void print(vector &v) { for (string s : v) { cout << s << '\n'; } } template void print(vector &v, int w = 0) { for (int i = 0; i < (int)v.size(); i++) { cout << right << setw(w) << v[i] << " \n"[i == (int)v.size() - 1]; } } template void print(vector> &v, int w = 0) { for (int i = 0; i < (int)v.size(); i++) { print(v[i], w); } } template void print(const T& arg) { cout << arg << '\n'; } template void print(const T& arg, const Args&... args) { cout << arg << ' '; print(args...); } int main() { ll n, m, k; cin >> n >> m >> k; vector a(n); rep(i,n) { cin >> a[i]; } queue q; q.emplace(0); vector b; b.emplace_back(0); rep(i,k/2) { queue tmp = q; while (!tmp.empty()) { ll now = tmp.front(); tmp.pop(); q.pop(); rep(j,n) { q.emplace(now+a[j]); b.emplace_back(now+a[j]); } } } queue q2; q2.emplace(0); vector c; c.emplace_back(0); rep(i,(k+1)/2) { queue tmp = q2; while (!tmp.empty()) { ll now = tmp.front(); tmp.pop(); q2.pop(); rep(j,n) { q2.emplace(now+a[j]); c.emplace_back(now+a[j]); } } } sort(All(b)); sort(All(c)); ll ans = 0; rep(i,b.size()) { ll now = b[i]; ll rest = m-now; auto itr = upper_bound(All(c), rest); ll idx = itr-c.begin(); if (idx == 0) continue; chmax(ans, now+c[idx-1]); } print(ans); }