#include <bits/stdc++.h>
using namespace std;
int seg[1 << 18];
int segn;
void init(int n) {
  segn = 1;
  while (segn < n) segn *= 2;
  for (int i = 0; i < segn * 2 - 1; i++) seg[i] = 0;
}
void add(int p, int x = 1) {
  p += segn - 1;
  seg[p] += x;
  while (p > 0) {
    p = (p - 1) / 2;
    seg[p] += x;
  }
}
int query(int a, int b, int k = 0, int l = 0, int r = segn) {
  if (r <= a || b <= l)
    return 0;
  else if (a <= l && r <= b)
    return seg[k];
  else {
    int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return vl + vr;
  }
}
long long s[100001];
int pos[100001];
vector<long long> cmp;
long long solve(int n, long long m) {
  int i;
  long long ans = 0;
  init(cmp.size());
  add(pos[0]);
  for (i = 1; i <= n; i++) {
    int r = upper_bound(cmp.begin(), cmp.end(), s[i] - m) - cmp.begin();
    ans += query(0, r);
    add(pos[i]);
  }
  return ans;
}
int main() {
  int n;
  long long k;
  scanf("%d %I64d", &n, &k);
  int i;
  s[0] = 0;
  for (i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    s[i + 1] = s[i] + x;
    cmp.push_back(s[i]);
  }
  cmp.push_back(s[n]);
  sort(cmp.begin(), cmp.end());
  for (i = 0; i <= n; i++)
    pos[i] = lower_bound(cmp.begin(), cmp.end(), s[i]) - cmp.begin();
  long long l = -1000000000000000LL, r = 1000000000000000LL;
  while (r - l > 1) {
    long long mid = (l + r) / 2;
    long long res = solve(n, mid);
    if (res <= k - 1)
      r = mid;
    else
      l = mid;
  }
  printf("%I64d\n", l);
  return 0;
}
