#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
inline long long input() {
  long long n;
  cin >> n;
  return n;
}
long long poww(long long a, long long b, long long md) {
  return (!b ? 1
             : (b & 1 ? a * poww(a * a % md, b / 2, md) % md
                      : poww(a * a % md, b / 2, md) % md));
}
const int MAXN = 1e5 + 10;
const int MAXLG = 18;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const long long INF = 8e18;
int n;
long long k;
long long a[MAXN];
long long dp[MAXN];
long long ps[MAXN];
long long val[MAXN];
void add_value(int v) {
  while (v <= n + 1) {
    val[v]++;
    v += (1 << __builtin_ctz(v));
  }
}
long long return_segment_num(int v) {
  long long res = 0;
  while (v) {
    res += val[v];
    v -= (1 << __builtin_ctz(v));
  }
  return res;
}
bool check(long long x) {
  memset(val, 0, sizeof(val));
  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    int ind = upper_bound(ps, ps + n + 1, dp[i] - x) - ps;
    ans += return_segment_num(ind);
    int tmp = lower_bound(ps, ps + n + 1, dp[i]) - ps + 1;
    add_value(tmp);
  }
  return (ans >= k);
}
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];
  }
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1] + a[i];
    ps[i] = dp[i];
  }
  sort(ps, ps + n + 1);
  long long l, r, mid;
  r = 1e15;
  l = -1e15;
  while (r - l > 1) {
    mid = (l + r) / 2;
    if (check(mid)) {
      l = mid;
    } else {
      r = mid;
    }
  }
  cout << l << "\n";
}
