#include <bits/stdc++.h>
using namespace std;
long long n, tree[100002];
vector<long long> pfx2;
int read(int idx) {
  long long sum = 0;
  while (idx > 0) {
    sum += tree[idx];
    idx -= (idx & -idx);
  }
  return sum;
}
void update(int idx, int val) {
  while (idx <= pfx2.size()) {
    tree[idx] += val;
    idx += (idx & -idx);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long k;
  cin >> n >> k;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long pfx[n + 1], pfx1[n + 1];
  pfx1[0] = pfx[0] = 0;
  for (int i = 0; i < n; i++) pfx1[i + 1] = pfx[i + 1] = pfx[i] + a[i];
  sort(pfx1, pfx1 + n + 1);
  for (int i = 0; i <= n; i++)
    if (i == 0 || pfx1[i] != pfx1[i - 1]) pfx2.push_back(pfx1[i]);
  long long l = -1000000000ll * n, r = 1000000000ll * n;
  while (l < r) {
    long long mid = (l + r + 1) / 2, cnt = 0;
    for (int i = 0; i < n + 2; i++) tree[i] = 0;
    for (int i = 0; i <= n; i++) {
      cnt += read(upper_bound(pfx2.begin(), pfx2.end(), pfx[i] - mid) -
                  pfx2.begin());
      update(lower_bound(pfx2.begin(), pfx2.end(), pfx[i]) - pfx2.begin() + 1,
             1);
    }
    if (cnt >= k)
      l = mid;
    else
      r = mid - 1;
  }
  cout << l << endl;
  return 0;
}
