#include <bits/stdc++.h>
using namespace std;
class taskE {
 public:
  const int BUBEN = 70;
  void solve() {
    int n;
    int64_t k;
    scanf("%d%I64d", &n, &k);
    vector<int> a(static_cast<unsigned long>(n));
    vector<int> tree(static_cast<unsigned long>(4 * n), 0);
    int64_t l = static_cast<int64_t>(0);
    int64_t r = static_cast<int64_t>(1e16);
    int64_t answer = -r;
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    for (int iter = 0; iter < BUBEN; iter++) {
      int64_t m = (l + r) / 2;
      int64_t mid = static_cast<int64_t>(-1e15) + m;
      fill(tree.begin(), tree.end(), 0);
      vector<int64_t> values;
      values.emplace_back(0);
      int64_t s = 0;
      for (int i = 0; i < n; i++) {
        s += a[i];
        values.emplace_back(s);
        values.emplace_back(s - mid);
      }
      auto update = [&](vector<int> &treee, int p) -> void {
        p += 2;
        for (; p < (int)treee.size(); p = (p | (p - 1)) + 1) {
          treee[p]++;
        }
      };
      auto request = [&](vector<int> &treeee, int p) -> int {
        p += 2;
        int s = 0;
        for (; p; p &= (p - 1)) {
          s += treeee[p];
        }
        return s;
      };
      sort(values.begin(), values.end());
      values.resize(static_cast<unsigned long>(
          unique(values.begin(), values.end()) - values.begin()));
      s = 0;
      update(tree,
             static_cast<int>(lower_bound(values.begin(), values.end(), 0) -
                              values.begin()));
      int64_t cnt = 0;
      for (int i = 0; i < n; i++) {
        s += a[i];
        int bound = static_cast<int>(
            lower_bound(values.begin(), values.end(), s - mid) -
            values.begin());
        cnt += request(tree, bound);
        update(tree,
               static_cast<int>(lower_bound(values.begin(), values.end(), s) -
                                values.begin()));
      }
      if (cnt < k) {
        r = m;
      } else {
        answer = max(answer, mid);
        l = m + 1;
      }
    }
    printf("%lld\n", answer);
  }
};
int main() {
  taskE solver;
  solver.solve();
  return 0;
}
