#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100, mod = 1e9 + 7, maxs = 321, maxa = 1e6 + 100, maxb = 24;
const long long inf = 2e18 + 4;
long long max(long long x, long long y) { return (x > y ? x : y); }
long long min(long long x, long long y) { return (x < y ? x : y); }
long long ps[maxn];
long long a[maxn];
long long BIT[maxn];
vector<pair<long long, long long> > v;
vector<pair<long long, long long> > cnt;
long long n, k;
long long get(int ind) {
  ind++;
  long long res = 0;
  while (ind > 0) {
    res += BIT[ind];
    ind -= ind & (-ind);
  }
  return res;
}
void update(int ind, int val) {
  ind++;
  while (ind < maxn) {
    BIT[ind] += val;
    ind += ind & (-ind);
  }
}
long long check(long long f) {
  fill(BIT, BIT + maxn, 0);
  v.clear();
  for (int i = 1; i <= n; i++) {
    long long s = ps[i] - f;
    v.push_back(make_pair(s, i));
  }
  sort(v.begin(), v.end());
  long long ans = 0;
  int p1 = 0, p2 = 0;
  while (p1 <= n && p2 < n) {
    while (p1 <= n && cnt[p1].first <= v[p2].first) {
      update(cnt[p1].second, 1);
      p1++;
    }
    while (p2 < n && v[p2].first < cnt[p1].first) {
      ans += get(v[p2].second - 1);
      p2++;
    }
  }
  return ans;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  cnt.push_back(make_pair(0, 0));
  for (int i = 1; i <= n; i++) {
    ps[i] = ps[i - 1] + a[i];
    cnt.push_back(make_pair(ps[i], i));
  }
  sort(cnt.begin(), cnt.end());
  cnt.push_back(make_pair(inf, inf));
  long long l = -1e17, r = 1e17;
  while (r - l > 1) {
    long long mid = (l + r) / 2;
    if (check(mid) >= k) {
      l = mid;
      continue;
    }
    r = mid;
  }
  cout << l << endl;
  return 0;
}
