#include<bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define MP make_pair
#define PB emplace_back
using namespace std;
const int SIZE = 1 << 20;
int a[SIZE];
int b[SIZE];
int A[40];
int T;
void dfs(int x,int bound, int v, int d[], int &num) {
    if(v > T) { return; }
    if(x == bound) {
        d[num++] = v;
        return;
    }
    dfs(x + 1, bound, v, d, num);
    dfs(x + 1, bound, v + A[x], d, num);
}
void solve() {
    int N;
    scanf("%d%d", &N, &T);
    for(int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    int a_num = 0;
    dfs(0, N/2, 0, a, a_num);
    int b_num = 0;
    dfs(N/2, N, 0, b, b_num);
    sort(a, a + a_num);
    sort(b, b + b_num);
    int ptr = b_num - 1;
    int ma = 0;
    for(int i = 0; i < a_num; i++) {
        while(ptr >= 0 && a[i] + b[ptr] > T) {
            ptr--;
        }
        if(ptr < 0) { break; }
        ma = max(ma, a[i] + b[ptr]);
    }
    printf("%d\n", ma);
}
int main() {
    solve();
    return 0;
}

// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 10/24/20 20:53:04
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,m; cin>>n>>m;
  if (m < 0 or (m != 0 and m >= n-1)) {
    cout << -1 << endl;
  } else {

    if (m == 0) {
      vector<pair<int,int>> LR;
      int k = 1;
      for (int i = 0; i < n; i++) {
        LR.emplace_back(k, k+1);
        k += 2;
      }
      for (auto [l,r] : LR)
        cout << l << " " << r << endl;
    } else {
      vector<pair<int,int>> LR;
      int k = 1;
      for (int i = 0; i < n-m-2; i++) {
        LR.emplace_back(k, k+1);
        k += 2;
      }
      LR.emplace_back(k, k+1+2*(m+1));
      k++;
      for (int i = 0; i < m+1; i++, k+=2)
        LR.emplace_back(k, k+1);

      for (auto [l,r] : LR)
        cout << l << " " << r << endl;
    }

  }

  return 0;
}
