#include <bits/stdc++.h>
using namespace std;
int n, b[111111], z;
long long a[111111], c[111111], k, l, m, h;
void upd(int x) {
  for (int i = x; i <= z; i += i & -i) b[i]++;
}
int sm(int x) { return x ? b[x] + sm(x ^ x & -x) : 0; }
bool ok() {
  for (int i = (1); i <= (z); i++) b[i] = 0;
  long long A = 0;
  for (int i = (0); i <= (n); i++) {
    int x = upper_bound(c, c + z, a[i] - m) - c;
    A += sm(x), x = lower_bound(c, c + z, a[i]) - c + 1;
    upd(x);
  }
  return A >= k;
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = (1); i <= (n); i++) cin >> a[i], c[i] = a[i] += a[i - 1];
  sort(c, c + n + 1);
  z = unique(c, c + n + 1) - c;
  long long ans = 1;
  for (h = 1LL << 47, l = -h; l <= h;) {
    m = l + h >> 1;
    if (ok())
      ans = m, l = m + 1;
    else
      h = m - 1;
  }
  cout << ans << endl;
}
