#include <bits/stdc++.h>
using namespace std;
class SegmentTree {
  vector<long long> values_;
  int offset_;
  vector<int> sums_;

 public:
  void Initialize(const vector<long long>& values) {
    values_ = values;
    offset_ = 1;
    while (offset_ <= values_.size()) {
      offset_ <<= 1;
    }
    sums_.resize(2 * offset_);
  }
  void Add(long long x, int v) {
    int index =
        lower_bound(values_.begin(), values_.end(), x) - values_.begin();
    index += offset_;
    while (index >= 1) {
      sums_[index] += v;
      index >>= 1;
    }
  }
  int GetBetween(long long left, long long right) {
    int l = lower_bound(values_.begin(), values_.end(), left) - values_.begin();
    int r = lower_bound(values_.begin(), values_.end(), right) -
            values_.begin() - 1;
    l += offset_;
    r += offset_;
    int result = 0;
    while (l <= r) {
      if (l & 1) result += sums_[l++];
      if (!(r & 1)) result += sums_[r--];
      l >>= 1;
      r >>= 1;
    }
    return result;
  }
};
const long long INF = 1e18;
bool CanBe(const vector<long long>& sums, SegmentTree& tree,
           const vector<long long>& values, long long threshold,
           long long max_more) {
  long long result = 0;
  tree.Add(sums[0], 1);
  for (int i = 1; i < sums.size(); ++i) {
    result += tree.GetBetween(-INF, sums[i] - threshold);
    tree.Add(sums[i], 1);
  }
  for (int i = 0; i < sums.size(); ++i) {
    tree.Add(sums[i], -1);
  }
  return result < max_more;
}
int main() {
  int n;
  long long k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  vector<long long> sums;
  sums.push_back(0);
  for (int i = 0; i < n; ++i) {
    sums.push_back(sums.back() + a[i]);
  }
  vector<long long> values = sums;
  sort(values.begin(), values.end());
  values.erase(unique(values.begin(), values.end()), values.end());
  SegmentTree tree;
  tree.Initialize(values);
  long long low = -1000000000LL * n;
  long long high = 1000000000LL * n;
  while (low < high - 1) {
    long long mid = (low + high) / 2;
    if (CanBe(sums, tree, values, mid, k)) {
      high = mid;
    } else {
      low = mid + 1;
    }
  }
  if (CanBe(sums, tree, values, low, k)) {
    cout << low << endl;
  } else {
    cout << high << endl;
  }
  return 0;
}
