#include <bits/stdc++.h>
using namespace std;
int numberToRemove(int i, int j, int year) {
// if (year == 337) {
// //cerr << "[" << i << "," << j << "] #";
// }
int tmp = 0;
for(int x = i; x> 0; x--) {
int rowBottles = (i-(x-1));
for(int y = j-rowBottles+1; y<= j;y++) {
if (y > 0 && y <= x) {
// if (year == 337) {
// //cerr << "(" << x << "," << y << "),";
// }
tmp++;
}
}
}
// if (year == 337) {
// cerr << "(" << i << ":" << j << ") -> " << tmp << endl;
// }
return tmp;
}
int main() {
//perf
ios_base::sync_with_stdio(0);
cin.tie(0);
//read input
int year = -1;
int n, k, a;
vector<pair<int,pair<int, int>>> v;
v.reserve((2000*2001)/2);
cin >> n >> k;
int piramid_size = (n*(n+1))/2;
int i = 1, j = 1;
for(int z = 1; z <= piramid_size; z++) {
cin >> a;
v.push_back(make_pair(a ,make_pair(i, j)));
j++;
if (j > i) {
i++;
j = 1;
}
}
//find solution
sort(v.begin(), v.end());
// cerr << "aaa";
for(int z = 0; z < v.size(); z++) {
pair<int,pair<int, int>> val = v.at(z);
// cerr << z << ":" << val.first << " ";
i = val.second.first;
j = val.second.second;
if (numberToRemove(i,j, val.first) <= k) {
year = val.first;
break;
}
}
//print solution
cout << year;
}