#include <bits/stdc++.h>
using namespace std;
int seg[8 * 100010];
void add(int v, int f, int e, int x, int val) {
  if (e - f == 1) {
    seg[v] = val;
    return;
  }
  int mid = (f + e) / 2;
  if (x < mid)
    add(2 * v, f, mid, x, val);
  else
    add(2 * v + 1, mid, e, x, val);
  seg[v] = seg[2 * v] + seg[2 * v + 1];
}
int get(int v, int f, int e, int l, int r) {
  if (f >= r || l >= e) return 0;
  if (f >= l && e <= r) return seg[v];
  int mid = (f + e) / 2;
  return get(2 * v, f, mid, l, r) + get(2 * v + 1, mid, e, l, r);
}
vector<pair<long long, int> > v;
int pl[100010];
int a[100010];
int main() {
  int n;
  cin >> n;
  long long k;
  cin >> k;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    v.push_back(pair<long long, int>(-sum, i));
    sum += a[i];
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) pl[v[i].second] = i;
  long long f = -1000000000000000000ll, e = 1000000000000000000ll,
            best = -1000000000000000000ll;
  while (e - f > 1) {
    memset(seg, 0, sizeof seg);
    long long mid = (f + e) / 2;
    long long addition = 0;
    long long maxA = 0;
    long long ok = 1000000000000000000ll;
    for (int i = 0; i < n; i++) {
      add(1, 0, n, pl[i], 1);
      addition += a[i];
      int p = lower_bound(v.begin(), v.end(),
                          pair<long long, int>(mid - addition, -1)) -
              v.begin();
      maxA += get(1, 0, n, p, n);
    }
    if (maxA < k)
      e = mid;
    else {
      best = mid;
      f = mid;
    }
  }
  cout << best << endl;
}
