#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 7;
const int M = 300;
const int mod = 999983;
const int inf = 1e9 + 7;
const double pi = acos(-1);
const int maxn = N * 2;
const double PI = acos(-1);
long long sum[N];
int a[N];
int n;
long long m;
int k;
map<long long, int> st;
int L[N];
void update(int u) {
  while (u) {
    L[u]++;
    u -= u & -u;
  }
}
int get(int u) {
  int ans = 0;
  while (u <= k) {
    ans += L[u];
    u += u & -u;
  }
  return ans;
}
bool check(long long x) {
  for (int i = 0; i <= k; i++) L[i] = 0;
  long long tol = 0;
  for (int i = n; i > 0; i--) {
    update(st[sum[i]]);
    typeof(st.begin()) it = st.lower_bound(sum[i - 1] + x);
    if (it == st.end()) continue;
    int v = it->second;
    tol += get(v);
  }
  return tol >= m;
}
void solve() {
  cin >> n >> m;
  st[0] = 0;
  for (int i = (1); i < (n + 1); i++) {
    scanf("%d", a + i);
    sum[i] = sum[i - 1] + a[i];
    st[sum[i]] = 0;
  }
  for (__typeof((st).begin()) it = (st).begin(); it != (st).end(); it++)
    it->second = ++k;
  long long lo = -1e14 - 7, hi = 1e14 + 7, res = -1;
  while (lo <= hi) {
    long long g = (lo + hi) >> 1;
    if (check(g)) {
      res = g;
      lo = g + 1;
    } else
      hi = g - 1;
  }
  cout << res;
}
int main() {
  int T = 1;
  for (int i = (1); i < (T + 1); i++) {
    solve();
  }
}
