#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
const int MD = 1000000007;
int n, a[N];
long long s[N], k;
int ft[N];
long long all[N];
int gt(int first) {
  int res = 0;
  for (int i = first; i >= 0; i &= i + 1, --i) res += ft[i];
  return res;
}
void upd(int first, int v) {
  for (int i = first; i < N; i |= i + 1) ft[i] += v;
}
long long chk(long long first) {
  memset(ft, 0, sizeof ft);
  for (int _tmp = (n), i = (0); i <= _tmp; ++i) all[i] = s[i];
  sort(all, all + n + 1);
  upd(lower_bound(all, all + n + 1, s[0]) - all, +1);
  long long res = 0;
  for (int _tmp = (n), i = (1); i <= _tmp; ++i) {
    res += gt(upper_bound(all, all + n + 1, s[i] - first) - all - 1);
    upd(lower_bound(all, all + n + 1, s[i]) - all, +1);
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int _tmp = (n), i = (1); i <= _tmp; ++i) {
    cin >> a[i];
    s[i] = a[i] + s[i - 1];
  }
  long long l = -1e14, r = 1e14, rs = 0;
  while (l <= r) {
    long long m = (l + r) / 2;
    if (chk(m) >= k) {
      l = m + 1;
      rs = m;
    } else {
      r = m - 1;
    }
  }
  cout << rs << endl;
  return 0;
}
