#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 9;
const long long mod = 1e9 + 7;
vector<pair<long long, long long> > vec;
int n;
int seg[maxn * 4];
int pos[maxn];
long long k;
long long a[maxn], ps[maxn];
void build(int l = 0, int r = n, int id = 1) {
  seg[id] = r - l;
  if (r - l > 1) {
    int mid = (l + r) >> 1;
    build(l, mid, id * 2);
    build(mid, r, id * 2 + 1);
  }
}
void update(int ind, int val, int l = 0, int r = n, int id = 1) {
  if (ind < l || ind >= r) return;
  if (r - l == 1) {
    seg[id] += val;
    return;
  }
  int mid = (l + r) >> 1;
  update(ind, val, l, mid, id * 2);
  update(ind, val, mid, r, id * 2 + 1);
  seg[id] = seg[id * 2] + seg[id * 2 + 1];
}
int get(long long val, int l = 0, int r = n, int id = 1) {
  if (vec[r - 1].first < val) return 0;
  if (vec[l].first >= val) return seg[id];
  int mid = (l + r) >> 1;
  return get(val, l, mid, id * 2) + get(val, mid, r, id * 2 + 1);
}
long long solve(long long val) {
  build();
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    res += get(val + ps[i - 1]);
    update(pos[i], -1);
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    ps[i] = ps[i - 1] + a[i];
  }
  for (int i = 1; i <= n; i++) vec.push_back(make_pair(ps[i], i));
  sort(vec.begin(), vec.end());
  for (int i = 0; i < n; i++) pos[vec[i].second] = i;
  long long l, r, mid;
  l = -1e15, r = 1e15;
  while (r - l > 1) {
    mid = (l + r) >> 1;
    if (solve(mid) < k)
      r = mid;
    else
      l = mid;
  }
  cout << l << "\n";
}
