#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const long long INF = 1e15;
long long A[N], s[N], fenw[N];
void add(int k, int v = 1) {
  for (; k < N; k += k & -k) fenw[k] += v;
}
long long get(int k) {
  long long sum = 0;
  for (; k > 0; k -= k & -k) sum += fenw[k];
  return sum;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> s[i];
  for (int i = 1; i <= n; i++) s[i] += s[i - 1];
  for (int i = 1; i <= n; i++) A[i] = s[i];
  sort(A, A + n + 1);
  long long lb = -INF, ub = INF;
  for (int _ = 0; _ < 100; _++) {
    long long x = (lb + ub) / 2;
    memset(fenw, 0, sizeof(fenw));
    long long res = 0;
    for (int i = 0; i <= n; i++) {
      res += get(upper_bound(A, A + n + 1, s[i] - x) - A);
      add(upper_bound(A, A + n + 1, s[i]) - A, 1);
    }
    if (res >= k)
      lb = x;
    else
      ub = x;
  }
  cout << lb << '\n';
  return 0;
}
