#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
long long a[N], s[N];
int n, m;
long long K;
int f(long long x) { return lower_bound(a, a + m, x) - a; }
int tree[N], tot[N * 20], ls[N * 20], rs[N * 20];
void pushup(int rt) { tot[rt] = tot[ls[rt]] + tot[rs[rt]]; }
int idx;
int update(int rt, int l, int r, int pos) {
  int nrt = ++idx;
  if (l == r) {
    tot[nrt] = tot[rt] + 1;
    return nrt;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid) {
    ls[nrt] = update(ls[rt], l, mid, pos);
    rs[nrt] = rs[rt];
  } else {
    ls[nrt] = ls[rt];
    rs[nrt] = update(rs[rt], mid + 1, r, pos);
  }
  pushup(nrt);
  return nrt;
}
int query(int rt, int ll, int rr, int mx) {
  if (ll == rr) {
    return tot[rt];
  }
  int mid = (ll + rr) >> 1;
  if (mx <= mid)
    return query(ls[rt], ll, mid, mx);
  else
    return tot[ls[rt]] + query(rs[rt], mid + 1, rr, mx);
}
long long cal(long long x) {
  long long ret = 0;
  for (int i = 1; i <= n; i++) {
    int loc = upper_bound(a, a + m, s[i] - x) - a - 1;
    if (loc < 0) continue;
    ret += query(tree[i], 0, m - 1, loc);
  }
  return ret;
}
int main() {
  scanf("%d%I64d", &n, &K);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    s[i + 1] = a[i + 1] = a[i] + x;
  }
  sort(a, a + n + 1);
  m = unique(a, a + n + 1) - a;
  for (int i = 0; i < n; i++) {
    int x = f(s[i]);
    tree[i + 1] = update(tree[i], 0, m - 1, x);
  }
  long long l = -(1LL << 60), r = (1LL << 60);
  while (l + 1 < r) {
    long long mid = (l + r) >> 1;
    if (cal(mid) >= K) {
      l = mid;
    } else {
      r = mid;
    }
  }
  cout << l << endl;
  return 0;
}
