#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
int _, cas;
using namespace std;
const int size = 110010, mod = 10001, inf = 0x3f3f3f3f, ninf = 0xc0c0c0c0;
const long long llmod = 4294967296ll, llinf = 0x3f3f3f3f3f3f3f3fll,
                llninf = 0xc0c0c0c00c0c0c0cll;
const double pi = acos(-1.0), eps = 1e-8;
int month[2][13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                    0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int nex[2][8] = {-1, 0, 1, 0, -1, 1, 1, -1, 0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline void inc(T& a, T b) {
  a = (a + b) % mod;
}
template <class T>
inline T modu(T a) {
  return (a % mod + mod) % mod;
}
template <class T>
inline T modu(T a, T mod) {
  return (a % mod + mod) % mod;
}
template <class T>
inline void crl(T* l, T* r, int step) {
  T tmp = *l;
  for (T* i = l; i < r; i += step) *i = *(i + step);
  *(r - 1) = tmp;
}
template <class T>
inline void crr(T* l, T* r, int step) {
  T tmp = *(r - 1);
  for (T* i = r - 1; i > l; i -= step) *i = *(i - step);
  *l = tmp;
}
bool inline dbeq(double a, double b) { return fabs(a - b) < eps; }
template <class T>
inline void cmin(T& a, T b) {
  a = min(a, b);
}
template <class T>
inline void cmax(T& a, T b) {
  a = max(a, b);
}
template <class T>
inline T max(T a, T b, T c) {
  return max(a, max(b, c));
}
template <class T>
inline T max(T a, T b, T c, T d) {
  return max(max(a, b, c), d);
}
template <class T>
inline T caldis(T a, T b, T c, T d) {
  return sqrt(((a - c) * (a - c)) + ((b - d) * (b - d)));
}
template <class T>
inline T first(T a, T b, T c, T d, T e, T f) {
  T x1 = c - a, y1 = d - b;
  T x2 = e - a, y2 = f - b;
  return x1 * y2 - x2 * y1;
}
inline int fastMax(int x, int y) {
  return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y;
}
inline int fastMin(int x, int y) {
  return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x;
}
long long ar[size], sum[size], mid, m, n;
vector<long long> br;
int loc(long long a) {
  return lower_bound(br.begin(), br.end(), a) - br.begin() + 1;
}
class bit {
 public:
  int c[size];
  void init() { memset(c, 0, sizeof(c)); }
  void add(int a, int v) {
    for (int i = a; i < size; i += i & -i) c[i] += v;
  }
  int sum(int a) {
    int sum = 0;
    for (int i = a; i > 0; i -= i & -i) sum += c[i];
    return sum;
  }
} bit;
bool solve() {
  long long ans = 0;
  bit.init();
  bit.add(loc(0), 1);
  for (int i = 1; i < n + 1; i++) {
    long long t = sum[i] - mid;
    int p = upper_bound(br.begin(), br.end(), t) - br.begin();
    ans += bit.sum(p);
    bit.add(loc(sum[i]), 1);
  }
  return ans >= m;
}
int main() {
  cin >> n >> m;
  br.push_back(0);
  for (int i = 1; i < n + 1; i++)
    cin >> ar[i], sum[i] = sum[i - 1] + ar[i], br.push_back(sum[i]);
  sort(br.begin(), br.end());
  br.erase(unique(br.begin(), br.end()), br.end());
  long long l = llninf, r = llinf;
  while (l < r) {
    mid = l + r >> 1;
    if (solve())
      l = mid + 1;
    else
      r = mid;
  }
  cout << l - 1 << endl;
  return 0;
}
