#include <bits/stdc++.h>
using namespace std;
const long long INF = 1ll << 50;
const int MAXN = 100 * 1000 + 321;
int a[MAXN], n;
long long ps[MAXN];
long long *seg[MAXN * 4];
void build(int v = 1, int s = 0, int e = n + 1) {
  seg[v] = new long long[e - s];
  if (e - s == 1) {
    seg[v][0] = ps[s];
    return;
  }
  int mid = (s + e) / 2, l = v * 2, r = v * 2 + 1;
  int ls = mid - s, rs = e - mid;
  build(l, s, mid);
  build(r, mid, e);
  merge(seg[l], seg[l] + ls, seg[r], seg[r] + rs, seg[v]);
}
int get(int l, int r, long long val, int v = 1, int s = 0, int e = n + 1) {
  if (r <= s || e <= l) return 0;
  if (l <= s && e <= r)
    return seg[v] + e - s - lower_bound(seg[v], seg[v] + e - s, val);
  int mid = (s + e) / 2;
  return get(l, r, val, v * 2, s, mid) + get(l, r, val, v * 2 + 1, mid, e);
}
long long solve(long long chk) {
  long long ans = 0;
  for (int i = 0; i < n; i++) ans += get(i + 1, n + 1, ps[i] + chk);
  return ans;
}
int32_t main() {
  long long k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  ps[0] = 0;
  for (int i = 0; i < n; i++) ps[i + 1] = ps[i] + a[i];
  build();
  long long l = -INF, r = INF;
  while (r - l > 1) {
    long long mid = (l + r) / 2;
    if (solve(mid) >= k)
      l = mid;
    else
      r = mid;
  }
  cout << l << endl;
}
