#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
const long long inf = 1e14 + 10;
long long n, k;
long long a[N];
long long ps[N];
long long fen[N];
vector<long long> vec;
void upd(long long x) {
  for (; x < N; x += (x & (-x))) {
    fen[x]++;
  }
}
long long get(long long x) {
  long long ret = 0;
  for (; x > 0; x -= (x & (-x))) {
    ret += fen[x];
  }
  return ret;
}
bool check(long long K) {
  long long res = 0;
  for (long long i = 0; i < N; i++) {
    fen[i] = 0;
  }
  for (long long i = 1; i <= n; i++) {
    long long val = ps[i] - K;
    long long ind = upper_bound(vec.begin(), vec.end(), val) - vec.begin();
    res += get(ind);
    ind = upper_bound(vec.begin(), vec.end(), ps[i]) - vec.begin();
    upd(ind);
    if (ps[i] >= K) {
      res++;
    }
  }
  if (res >= k) {
    return true;
  } else {
    return false;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    ps[i] = ps[i - 1] + a[i];
    vec.push_back(ps[i]);
  }
  sort(vec.begin(), vec.end());
  long long L = -inf;
  long long R = inf;
  while (R - L > 1) {
    long long mid = (L + R) / 2;
    if (check(mid)) {
      L = mid;
    } else {
      R = mid;
    }
  }
  cout << L;
  return 0;
}
