#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%I64d", &x);
  return x;
}
const int N = 1e5 + 10;
const long long inf = 1e18;
const long double eps = 1e-12;
int n, sz;
long long k, fen[N], a[N], b[N];
void clr() {
  for (int i = 0; i < N; i++) fen[i] = 0;
}
void upd(int ind) {
  ind++;
  for (; ind < N; ind += (ind & -ind)) fen[ind]++;
}
long long get(int ind) {
  return ind ? fen[ind] + get(ind - (ind & (-ind))) : 0;
}
bool ok(long long x) {
  clr();
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    int idx = int(upper_bound(b, b + sz, a[i] - x) - b);
    cnt += get(idx);
    idx = int(lower_bound(b, b + sz, a[i]) - b);
    upd(idx);
  }
  return (cnt >= k);
}
int main() {
  n = in();
  n++;
  k = lin();
  for (int i = 1; i < n; i++) a[i] = lin();
  for (int i = 1; i < n; i++) a[i] += a[i - 1], b[i] = a[i];
  sort(b, b + n);
  sz = int(unique(b, b + n) - b);
  long long l = -inf, r = inf;
  while (r - l > 1) {
    long long m = (l + r) / 2;
    if (ok(m))
      l = m;
    else
      r = m;
  }
  cout << l << endl;
  return 0;
}
