#include <bits/stdc++.h>
using namespace std;
char buf[25];
const long long N = 100010;
struct edge {
  long long lc, rc, v;
} t[5000010];
long long a[N], c[N], root[N];
long long n, k, num;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (!x) {
    putchar('0');
    return;
  }
  long long cnt = 0;
  while (x) {
    buf[++cnt] = '0' + x % 10;
    x /= 10;
  }
  for (long long i = cnt; i >= 1; --i) putchar(buf[i]);
}
long long insert(long long x, long long l, long long r, long long v) {
  long long y = ++num;
  t[y].lc = t[x].lc;
  t[y].rc = t[x].rc;
  t[y].v = t[x].v + 1;
  if (l == r) return y;
  long long mid = (l + r) >> 1;
  if (v <= mid) t[y].lc = insert(t[x].lc, l, mid, v);
  if (mid + 1 <= v) t[y].rc = insert(t[x].rc, mid + 1, r, v);
  return y;
}
long long query(long long x, long long l, long long r, long long v) {
  if (l > v) return 0;
  if (r <= v) return t[x].v;
  long long mid = (l + r) >> 1, ans = 0;
  ans = query(t[x].lc, l, mid, v);
  if (mid + 1 <= v) ans += query(t[x].rc, mid + 1, r, v);
  return ans;
}
bool solve(long long x, long long l, long long r) {
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) {
    ans += query(root[i - 1], l, r, c[i] - x);
    if (ans >= k) return true;
  }
  return false;
}
void serch() {
  long long l = 0, r = 0;
  for (long long i = 1; i <= n; ++i)
    if (a[i] < 0)
      l += a[i];
    else
      r += a[i];
  root[0] = insert(0, l, r, 0);
  for (long long i = 1; i <= n; ++i) root[i] = insert(root[i - 1], l, r, c[i]);
  long long MIN = l, MAX = r;
  while (l < r) {
    long long mid = (l + r + 1) >> 1;
    if (solve(mid, MIN, MAX))
      l = mid;
    else
      r = mid - 1;
  }
  write(l);
  putchar('\n');
}
signed main() {
  n = read();
  k = read();
  for (long long i = 1; i <= n; ++i) {
    a[i] = read();
    c[i] = c[i - 1] + a[i];
  }
  serch();
  return 0;
}
