#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
const char SPACE = ' ', ENDL = '\n';
const int BASE = (int)1e9 + 7;
const int MODULO = BASE;
int ri() {
  int v;
  cin >> v;
  return v;
}
long long rll() {
  long long v;
  cin >> v;
  return v;
}
string rs() {
  string s;
  cin >> s;
  return s;
}
vector<int> rvi(int n) {
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  return a;
}
void read_graph(int n, int edges, vector<vector<int>>& graph,
                bool oriented = false) {
  graph.assign(n, vector<int>());
  for (int e = 0; e < edges; ++e) {
    int from = ri() - 1;
    int to = ri() - 1;
    graph[from].push_back(to);
    if (!oriented) graph[to].push_back(from);
  }
}
bool yn(bool result) {
  cout << (result ? "YES" : "NO") << ENDL;
  return result;
}
int get_bit(int mask, int bit) { return (mask >> bit) & 1; }
int init_input() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int local_tests = 1;
  return local_tests;
}
template <class T>
int indexOf(vector<T>& sorted, T value) {
  auto it = lower_bound(sorted.begin(), sorted.end(), value);
  if (sorted.end() == it) return ~sorted.size();
  int index = it - sorted.begin();
  if (value < sorted[index]) {
    index = ~index;
  }
  return index;
}
template <class T>
pair<vector<int>, vector<T>> compress(vector<T>& values) {
  vector<T> sorted = values;
  sort(sorted.begin(), sorted.end());
  sorted.resize(unique(sorted.begin(), sorted.end()) - sorted.begin());
  vector<int> result(values.size());
  for (int i = 0; i < values.size(); ++i) {
    result[i] = indexOf(sorted, values[i]);
  }
  return {result, sorted};
}
class FenwickTree {
  size_t size;
  vector<long long> t;
  vector<long long> values;

 public:
  FenwickTree(size_t n) : size(n + 1), t(size, 0LL), values(size, 0LL) {}
  void update_tree_index(int index, long long delta) {
    for (; (size_t)index < size; index += index & -index) {
      t[index] += delta;
    }
  }
  void update_value(size_t index, long long value) {
    long long delta = value - values[index + 1];
    increase_value(index, delta);
  }
  void increase_value(size_t index, long long delta) {
    ++index;
    values[index] += delta;
    update_tree_index(index, delta);
  }
  long long get_prefix_sum(int index) {
    ++index;
    long long sum = 0;
    for (; index > 0; index -= index & -index) {
      sum += t[index];
    }
    return sum;
  }
  pair<size_t, long long> get_max_prefix_lower(long long value) {
    size_t result = 0;
    long long sum = 0;
    for (int bit = 20; bit >= 0; --bit) {
      size_t next = result | (1 << bit);
      if (next < size && sum + t[next] < value) {
        result = next;
        sum += t[next];
      }
    }
    return {result, sum};
  }
  void clear() {
    t.assign(size, 0LL);
    values.assign(size, 0LL);
  }
};
void solve_test() {
  int tests = 1;
  while (tests-- > 0) {
    int n = ri();
    long long k = rll();
    vector<int> a = rvi(n);
    vector<long long> pref(n + 1, 0);
    for (int i = 0; i < n; ++i) {
      pref[i + 1] = pref[i] + a[i];
    }
    auto compress_res = compress(pref);
    vector<int>& ids = compress_res.first;
    vector<long long>& sorted = compress_res.second;
    long long inf = (long long)n * (long long)1e9 + 1;
    long long left = -inf;
    long long right = inf;
    FenwickTree tree(sorted.size());
    while (right - left > 1) {
      long long mid = (left + right) / 2;
      long long cnt = 0;
      tree.clear();
      for (size_t i = 0; i < pref.size(); ++i) {
        long long mv = pref[i] - mid;
        int id = indexOf(sorted, mv);
        if (id < 0) {
          id = (~id) - 1;
        }
        long long starts = tree.get_prefix_sum(id);
        cnt += starts;
        tree.increase_value(ids[i], 1);
      }
      if (k <= cnt) {
        left = mid;
      } else {
        right = mid;
      }
    }
    cout << left << ENDL;
  }
}
int main() {
  int local_tests = init_input();
  for (int local_test = 0; local_test < local_tests; ++local_test) {
    solve_test();
  }
  return 0;
}
