#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double EPS = 1e-9;
const double PI = acos(-1.);
const long long LL_INF = 1e17 + 16;
const int INF = 1e9 + 10;
const long long MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
int n;
long long k;
int v[MAXN];
pair<long long, int> pp[MAXN];
long long bs_vals[MAXN];
int per[MAXN];
int ft[MAXN];
void add(int ind) {
  for (int i = ind; i <= n; i = (i | (i + 1))) {
    ft[i]++;
  }
}
int get(int r) {
  int ans = 0;
  for (int i = r; i >= 0; i = (i & (i + 1)) - 1) {
    ans += ft[i];
  }
  return ans;
}
bool check(long long mid) {
  for (int i = (0); i < (int)(n); i++) {
    ft[i] = 0;
  }
  long long offset = 0;
  long long cur = 0;
  for (int i = n - 1; i >= 0; i--) {
    int ind = lower_bound(bs_vals, bs_vals + n, mid + offset) - bs_vals;
    int ge = n - ind;
    int deleted = n - 1 - i;
    if (ind) {
      deleted -= get(ind - 1);
    }
    cur += ge - deleted;
    add(per[i]);
    offset += v[i];
  }
  return cur >= k;
}
void solve() {
  scanf("%d%lld", &n, &k);
  for (int i = (0); i < (int)(n); i++) {
    scanf("%d", &v[i]);
  }
  long long sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    sum += v[i];
    pp[i] = make_pair(sum, i);
  }
  sort(pp, pp + n);
  for (int i = (0); i < (int)(n); i++) {
    bs_vals[i] = pp[i].first;
    per[pp[i].second] = i;
  }
  long long l = -1e15 - 50, r = 1e15 + 50;
  for (; l + 1 < r;) {
    long long mid = (l + r) >> 1;
    if (check(mid)) {
      l = mid;
    } else {
      r = mid;
    }
  }
  printf("%lld\n", l);
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
