#include <bits/stdc++.h>
using namespace std;
struct el {
  long long idx;
  long long st;
};
el a[1 << 17];
long long K;
long long N;
long long it[1 << 17];
void scan() {
  scanf("%d%I64d\n", &N, &K);
  for (long long i = 1; i <= N; ++i) {
    scanf("%I64d", &a[i].st);
    a[i].idx = i;
  }
}
void update(long long idx, long long st) {
  for (; idx < (1 << 17); idx += (idx & (-idx))) it[idx] += st;
}
long long query(long long idx) {
  if (!idx) return 0;
  long long res = 0;
  for (; idx; idx -= (idx & (-idx))) res += it[idx];
  return res;
}
long long f(long long lim) {
  long long res = 0;
  long long idx = 0;
  memset(it, 0, sizeof(it));
  for (long long i = 1; i <= N; ++i) update(i, 1);
  for (long long i = 0; i < N; ++i) {
    while (a[i].st - a[idx].st > lim) {
      update(a[idx].idx + 1, -1);
      ++idx;
    }
    res += query(a[i].idx);
  }
  memset(it, 0, sizeof(it));
  idx = N - 1;
  for (long long i = 1; i <= N; ++i) update(i, 1);
  for (long long i = N - 1; i >= 0; --i) {
    if (idx >= 0)
      while (a[i].st - a[idx].st > min(-lim - 1, lim)) {
        update(a[idx].idx + 1, -1);
        --idx;
        if (idx < 0) break;
      }
    res += (query(1e5 + 6) - query(a[i].idx + 1));
  }
  memset(it, 0, sizeof(it));
  return res;
}
long long cmp(el t1, el t2) { return t1.st < t2.st; }
void solve() {
  K = N * (N + 1) / 2 - K + 1;
  for (long long i = 1; i <= N; ++i) a[i].st += a[i - 1].st;
  sort(a, a + N + 1, cmp);
  ++N;
  a[N].st = 1e16;
  long long l = -1e15, r = 1e15;
  while (l + 5 < r) {
    long long mid = (l + r) / 2;
    if (f(mid) < K)
      l = mid;
    else
      r = mid;
  }
  while (f(l) < K) ++l;
  printf("%I64d\n", l);
}
int main() {
  scan();
  solve();
}
