#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, a[maxn];
long long C[maxn], s[maxn], inf = 0x3f3f3f3f3f3f3f3fLL, val[maxn], sz, k;
long long lowbit(long long x) { return x & -x; }
long long _sum(long long m) {
  long long ret = 0;
  while (m) {
    ret += C[m];
    m -= lowbit(m);
  }
  return ret;
}
void _add(long long m, long long k) {
  while (m <= sz) {
    C[m] += k;
    m += lowbit(m);
  }
}
bool check(long long x) {
  long long ret = 0;
  memset(C, 0, sizeof C);
  for (int i = 1; i <= n; i++) {
    _add(s[i - 1], 1);
    ret += _sum(lower_bound(val, val + sz, val[s[i] - 1] - x) - val);
  }
  return ret < k;
}
int main() {
  scanf("%d%lld", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    s[i] = s[i - 1] + a[i];
  }
  for (int i = 0; i <= n; i++) val[sz++] = s[i];
  sort(val, val + sz);
  sz = unique(val, val + sz) - val;
  for (int i = 0; i <= n; i++) {
    s[i] = lower_bound(val, val + sz, s[i]) - val + 1;
  }
  long long l = -inf, r = inf;
  while (l < r) {
    long long mid = l + (r - l) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%lld", r);
}
