#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:128777216")
using namespace std;
struct Tree {
 private:
  int a[1 << 18];
  int n;

 public:
  void init(int n) {
    this->n = n;
    memset(a, 0, sizeof(a));
  }
  void add(int x) {
    int l = 0, r = n, i = 0;
    while (r - l > 1) {
      a[i]++;
      int mid = (l + r) >> 1;
      if (x < mid) {
        i += i + 1;
        r = mid;
      } else {
        i += i + 2;
        l = mid;
      }
    }
    a[i]++;
  }
  int count(int x) {
    int i = 0, l = 0, r = n;
    int res = 0;
    while (r - l > 1) {
      int mid = (l + r) >> 1;
      if (x < mid) {
        r = mid;
        i += i + 1;
      } else {
        res += a[i + i + 1];
        i += i + 2;
        l = mid;
      }
    }
    res += a[i];
    return res;
  }
} tree;
int a[100010];
long long s[100010];
long long x[100010];
int main() {
  int n;
  long long k;
  cin >> n >> k;
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
    s[i] = x[i] = sum;
  }
  sort(x, x + n + 1);
  int m = unique(x, x + n + 1) - x;
  for (int i = 0; i <= n; i++) {
    a[i] = (lower_bound(x, x + m, s[i]) - x);
  }
  long long l = -100000000000000LL, r = -l, res = 0;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    tree.init(m);
    tree.add(a[0]);
    long long cur = 0;
    for (int i = 1; i <= n; i++) {
      int v = (upper_bound(x, x + m, s[i] - mid) - x) - 1;
      if (v >= 0) {
        cur += tree.count(v);
      }
      if (cur >= k) break;
      tree.add(a[i]);
    }
    if (cur >= k) {
      res = mid;
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  cout << res << endl;
  return 0;
}
