#include <bits/stdc++.h>
using namespace std;
int N;
long long k, s[100005];
int rep[100005], bit[100005], pos[100005];
struct val {
  long long sum;
  int id;
  bool operator<(const val &k) const { return sum < k.sum; }
} v[100005];
int query(int p) {
  int ans = 0;
  while (p > 0) {
    ans += bit[p];
    p -= p & (-p);
  }
  return ans;
}
void upd(int p) {
  while (p <= N) {
    bit[p]++;
    p += p & (-p);
  }
}
bool f(long long crit) {
  long long val = crit;
  for (int i = N; i > 0; i--) {
    int lt = 0, rt = N + 1;
    while (rt - lt > 1) {
      int m = (lt + rt) / 2;
      if (v[m].sum >= val)
        rt = m;
      else
        lt = m;
    }
    pos[i] = rt;
    val += s[i];
  }
  memset(bit, 0, sizeof(bit));
  long long ccmp = 0;
  for (int i = N; i > 0; i--) {
    ccmp += N + 1 - pos[i];
    ccmp -= query(N + 1 - pos[i]);
    upd(N + 1 - rep[i]);
  }
  return ccmp >= k;
}
int main() {
  cin >> N >> k;
  for (int i = 1; i <= N; i++) cin >> s[i];
  long long cur = 0;
  for (int i = N; i > 0; i--) {
    cur = cur + s[i];
    v[i].id = i;
    v[i].sum = cur;
  }
  sort(v + 1, v + 1 + N);
  for (int i = 1; i <= N; i++) rep[v[i].id] = i;
  long long l = -1E17, r = 1E17;
  while (r - l > 1) {
    long long m = (l + r) / 2;
    if (f(m))
      l = m;
    else
      r = m;
  }
  cout << l << endl;
  return 0;
}
