#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 9;
long long n, k, l, r, a[MAX], pre[MAX], f[MAX];
vector<long long> b;
void upd(long long v, long long val) {
  for (v++; v < MAX; v += v & -v) f[v] += val;
}
long long gt(long long v) {
  if (v < 0) return 0;
  long long ret = 0;
  for (v++; v; v -= v & -v) ret += f[v];
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> k, b.push_back(0);
  for (int i = 1; i <= n; i++)
    cin >> a[i], pre[i] = a[i] + pre[i - 1], b.push_back(pre[i]);
  sort(b.begin(), b.end()), b.resize(unique(b.begin(), b.end()) - b.begin());
  for (int i = 0; i <= n; i++)
    pre[i] = lower_bound(b.begin(), b.end(), pre[i]) - b.begin();
  l = -1e15, r = 1e15;
  while (l < r - 1) {
    long long mid = (l + r) >> 1, ret = 0;
    memset(f, 0, sizeof f), upd(pre[0], +1);
    for (int i = 1; i <= n; i++)
      ret +=
          gt(upper_bound(b.begin(), b.end(), b[pre[i]] - mid) - b.begin() - 1),
          upd(pre[i], +1);
    if (ret < k)
      r = mid;
    else
      l = mid;
  }
  cout << l;
  return 0;
}
