#include <iostream>
#include <set>
using namespace std;
class Wino {
public:
int y = 0;
int ileNadZ = 0;
bool operator< (const Wino& msgObj) const {
return (this->y < msgObj.y);
}
friend ostream& operator<<(ostream& os, const Wino& obj);
};
ostream& operator<<(ostream& os, const Wino& obj)
{
os << "Wino" << obj.y << ";" << obj.ileNadZ;
return os;
}
int p(int lvl) {
return (lvl + 1) * lvl / 2;
}
int main(int argc, char** argv) {
int n, k;
cin >> n >> k;
Wino* najstarsze = NULL;
for (int i = 0; i < n; i++) {
bool czyJakisZK = false;
for (int j = 0; j <= i; j++) {
int year;
cin >> year;
Wino* w = new Wino();
w->y = year;
w->ileNadZ = p(i + 1) - p(j) - p(i - j);
if (w->ileNadZ <= k) {
if (najstarsze == 0 || (najstarsze->y >= w->y)) {
najstarsze = w;
}
czyJakisZK = true;
}
}
if (!czyJakisZK)
break;
}
if (najstarsze != NULL)
cout << najstarsze->y << endl;
return 0;
}