#include <bits/stdc++.h>
const long long inf = 1ll << 50;
int n;
long long fw[101010], a[101010], b[101010];
void update(int idx) {
  while (idx <= n + 1) {
    ++fw[idx];
    idx += idx & -idx;
  }
}
int query(int idx) {
  int res = 0;
  while (idx >= 1) {
    res += fw[idx];
    idx -= idx & -idx;
  }
  return res;
}
int main() {
  long long k;
  scanf("%d %I64d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%I64d", a + i);
    a[i] += a[i - 1];
    b[i] = a[i];
  }
  std::sort(b, b + n + 1);
  long long ans = -inf, lo = -inf, hi = inf;
  while (lo <= hi) {
    long long mi = (lo + hi) >> 1;
    memset(fw, 0, sizeof(fw));
    long long cnt = 0;
    for (int i = 0; i <= n; ++i) {
      int pos = std::upper_bound(b, b + n + 1, a[i] - mi) - b;
      cnt += query(pos);
      pos = std::lower_bound(b, b + n + 1, a[i]) - b + 1;
      update(pos);
    }
    if (cnt >= k) {
      lo = mi + 1;
      ans = mi;
    } else {
      hi = mi - 1;
    }
  }
  printf("%I64d", ans);
}
