#include <bits/stdc++.h>
using namespace std;
int tmp;
long long n, k, ans = -100000000000009;
long long v[100005];
set<long long> S;
map<long long, int> M;
int T[100005];
void upd(int x) {
  for (; x <= tmp; x += x & -x) T[x]++;
}
int tap(int x) {
  int ret = 0;
  for (; x > 0; x -= x & -x) ret += T[x];
  return ret;
}
bool ok(long long x) {
  memset(T, 0, sizeof(T));
  upd(M[0]);
  long long q = 0;
  for (int i = 1; i <= n; i++) {
    q += tap(M[*--S.upper_bound(v[i] - x)]);
    upd(M[v[i]]);
  }
  return (q >= k);
}
int main() {
  scanf("%lld%lld", &n, &k);
  S.insert(0);
  S.insert(100000000000009);
  S.insert(-100000000000009);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &v[i]);
    v[i] += v[i - 1];
    M[v[i]] = 1;
    S.insert(v[i]);
  }
  M[0] = 1;
  for (auto i : M) M[i.first] = ++tmp;
  long long h = -100000000000009, t = 100000000000009, m;
  while (h + 1 < t) {
    m = (h + t) / 2;
    if (ok(m))
      h = m;
    else
      t = m;
  }
  printf("%lld\n", h);
}
