#include <bits/stdc++.h>
using namespace std;
int n, tree[100005];
long long in[100005], id[100005], k, l, r, mid;
inline int low(int x) { return x & -x; }
void add(int x) {
  for (; x <= n + 1; x += low(x)) tree[x]++;
}
int query(int x) {
  int re = 0;
  for (; x > 0; x -= low(x)) re += tree[x];
  return re;
}
int bs(long long x) {
  int ll = 1, rr = n + 1, mm;
  if (id[1] > x) return -1;
  while (ll < rr - 1) {
    mm = (ll + rr) >> 1;
    if (id[mm] <= x)
      ll = mm;
    else
      rr = mm - 1;
  }
  if (ll == rr - 1 && id[rr] <= x) ll++;
  return ll;
}
bool check(long long x) {
  long long re = 0;
  memset(tree, 0, sizeof(tree));
  add(bs(0));
  for (int i = 1; i <= n; i++) {
    long long tmp = in[i] - x;
    int pos = bs(tmp);
    if (pos > 0) re += query(pos);
    add(bs(in[i]));
  }
  return re >= k;
}
int main() {
  while (~scanf("%d %I64d", &n, &k)) {
    in[0] = 0;
    for (int i = 1; i <= n; i++) scanf("%I64d", &in[i]);
    for (int i = 1; i <= n; i++) {
      in[i] += in[i - 1];
      id[i] = in[i];
    }
    id[n + 1] = 0;
    sort(id + 1, id + n + 2);
    l = -(long long)1e14, r = (long long)1e14;
    while (l < r - 1) {
      mid = (l + r) / 2;
      if (check(mid))
        l = mid;
      else
        r = mid - 1;
    }
    if (l == r - 1 && check(r)) l++;
    printf("%I64d\n", l);
  }
  return 0;
}
