#include <bits/stdc++.h>
using namespace std;
const int MAXN = (1 << 17) + 1;
const long long OO = (1LL << 60);
struct Tree {
  long long mapping[MAXN];
  int n, m;
  int cnt[MAXN * 2];
  void init(int n) {
    m = n;
    for (this->n = 1; this->n < n; this->n *= 2)
      ;
    sort(mapping, mapping + m);
    m = unique(mapping, mapping + m) - mapping;
  }
  void clear() {
    for (int i = (0); i < (2 * n); ++i) cnt[i] = 0;
  }
  void put(long long elem) {
    if (0) cout << "put(" << elem << ")\n";
    for (int idx = map(elem) + n; idx > 0; idx /= 2) cnt[idx] += 1;
  }
  int _greaterEqualCount(int idx) {
    idx += n;
    int res = cnt[idx];
    while (idx > 1) {
      if (idx % 2 == 0) res += cnt[idx + 1];
      idx /= 2;
    }
    return res;
  }
  int greaterEqualCount(long long elem) {
    int idx = map(elem);
    if (idx == m) return 0;
    return _greaterEqualCount(idx);
  }
  int map(long long elem) {
    return lower_bound(mapping, mapping + m, elem) - mapping;
  }
  void printc() {
    for (int i = (0); i < (m); ++i) {
      if (0)
        cout << "i"
             << ":" << (i) << " "
             << "mapping[i]"
             << ":" << (mapping[i]) << " "
             << "_greaterEqualCount(i)"
             << ":" << (_greaterEqualCount(i)) << " " << endl;
    }
  }
} t;
long long a[MAXN];
long long s[MAXN];
int n;
long long getCount(long long resp) {
  t.clear();
  long long res = 0;
  for (int i = (0); i < (n); ++i) {
    if (0)
      cout << endl
           << "i"
           << ":" << (i) << " "
           << "res"
           << ":" << (res) << " " << endl;
    t.printc();
    res -= t.greaterEqualCount(s[i] + resp);
    t.put(s[i + 1]);
  }
  for (int i = (0); i < (n); ++i) {
    if (0)
      cout << endl
           << "i"
           << ":" << (i) << " "
           << "res"
           << ":" << (res) << " " << endl;
    res += t.greaterEqualCount(s[i] + resp);
  }
  if (0) cout << "getCount(" << resp << "):" << res << endl;
  return res;
}
int main() {
  long long k;
  cin >> n >> k;
  for (int i = (0); i < (n); ++i) {
    cin >> a[i];
  }
  t.mapping[0] = s[0] = 0;
  for (int i = (1); i < (n + 1); ++i) t.mapping[i] = s[i] = s[i - 1] + a[i - 1];
  t.init(n + 1);
  long long low = -OO;
  long long high = OO;
  while (high - low > 1) {
    long long mid = (high + low) / 2;
    if (getCount(mid) < k)
      high = mid;
    else
      low = mid;
  }
  cout << low << endl;
  return 0;
}
