#include <bits/stdc++.h>
using namespace std;
long long a[100001], t[100001], z[100001], first, last, mid, key, n, ts,
    b[100001], k, i, cs[100001];
bool cmp(long i1, long j1) { return a[i1] < a[j1]; }
long long get(long i1) {
  long long t1 = 0;
  while (i1 > 0) {
    t1 += t[i1];
    i1 -= i1 & (-i1);
  }
  return t1;
}
void up(long i1) {
  while (i1 <= key) {
    t[i1]++;
    i1 += i1 & (-i1);
  }
}
long long search(long long x) {
  memset(t, 0, sizeof(t));
  long long tt = 0, h1;
  long first1, last1, mid1;
  for (int i1 = 1; i1 <= n; i1++) {
    first1 = 0;
    last1 = ts + 1;
    h1 = z[i1] - x;
    while (first1 + 1 < last1) {
      mid1 = (first1 + last1) >> 1;
      if (a[mid1] <= h1)
        first1 = mid1;
      else
        last1 = mid1;
    }
    if (z[i1] >= x) tt++;
    if (first1 > 0) tt += get(first1);
    up(b[i1]);
  }
  return tt;
}
int main() {
  cin >> n >> k;
  a[0] = z[0] = 0;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
    z[i] = a[i];
    cs[i] = i;
  }
  sort(cs + 1, cs + n + 1, cmp);
  key = 0;
  for (i = 1; i <= n; i++)
    if (i == 1 || (i > 1 && a[cs[i]] != a[cs[i - 1]])) {
      key++;
      b[cs[i]] = key;
    } else
      b[cs[i]] = key;
  sort(a + 1, a + n + 1);
  ts = 0;
  for (i = 1; i <= n; i++)
    if (i == 1 || (i > 1 && a[i] != a[ts])) {
      ts++;
      a[ts] = a[i];
    }
  first = -10000000000000000LL;
  last = 10000000000000000LL;
  while (first + 1 < last) {
    mid = (first + last) >> 1;
    if (search(mid) >= k)
      first = mid;
    else
      last = mid;
  }
  cout << first;
}
