#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 20;
long long s[N], b[N], f[N];
int n, cnt;
long long k;
long long sum(int x) {
  long long ret = 0;
  while (x) {
    ret += f[x];
    x -= (-x) & x;
  }
  return ret;
}
void add(int x) {
  while (x <= cnt) {
    f[x]++;
    x += x & (-x);
  }
}
bool pd(long long x) {
  for (int i = 0; i <= cnt; i++) f[i] = 0;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] >= x) ans++;
    long long t = s[i] - x;
    int a = upper_bound(b + 1, b + cnt + 1, t) - b - 1;
    int c = lower_bound(b + 1, b + cnt + 1, s[i]) - b;
    ans += sum(a);
    add(c);
  }
  return ans >= k;
}
int main() {
  scanf("%d%lld", &n, &k);
  int x;
  for (int i = 1; i <= n; i++)
    scanf("%d", &x), s[i] = s[i - 1] + x, b[i] = s[i];
  sort(b + 1, b + n + 1);
  cnt = unique(b + 1, b + n + 1) - b - 1;
  long long l = -1e14, r = 1e14, best = -1;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (pd(mid))
      best = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%lld\n", best);
  return 0;
}
