#include <bits/stdc++.h>
using namespace std;
const int maxn = 100003;
struct data {
  long long val;
  int pos;
  data() {}
  data(long long v, int p) { val = v, pos = p; }
  bool operator<(const data &a) const {
    if (val == a.val) return pos < a.pos;
    return val < a.val;
  }
} s[maxn];
int n, c[maxn];
long long k, l, r, mid;
long long get() {
  long long f = 0, v = 0;
  char ch;
  while (!isdigit(ch = getchar()))
    if (ch == '-') break;
  if (ch == '-')
    f = 1;
  else
    v = ch - 48;
  while (isdigit(ch = getchar())) v = v * 10 + ch - 48;
  if (f == 1)
    return -v;
  else
    return v;
}
void Insert(int x) {
  for (; x <= n; x += x & -x) c[x]++;
}
int Calc(int x) {
  int res = 0;
  for (; x > 0; x -= x & -x) res += c[x];
  return res;
}
long long calc(long long lim) {
  memset(c, 0, sizeof(c));
  long long res = 0;
  for (int i = 1, j = 1; i <= n; i++) {
    while (j <= n && s[i].val - s[j].val >= lim) Insert(s[j++].pos);
    res += Calc(s[i].pos - 1);
  }
  return res;
}
int main() {
  n = get();
  k = get();
  for (int i = 1; i <= n; i++) {
    int x = get();
    s[i] = data(s[i - 1].val + x, i + 1), x > 0 ? r += x : l += x;
  }
  s[++n] = data(0, 1);
  sort(s + 1, s + 1 + n);
  while (l < r) {
    mid = (l + r + 1) / 2;
    if (calc(mid) >= k)
      l = mid;
    else
      r = mid - 1;
  }
  printf("%I64d\n", l);
  return 0;
}
