#include using namespace std; using ll = long long; using ull = unsigned long long; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); /* clamp関数は広義単調 f(x)>=Yを満たす最小のxが答えになりうる。 */ ll N, Y, a, b; cin >> N >> Y; vector s(N); for (int i=0; i> s[i]; auto f=[&](ull x)->ull{ vector v; for (int i=0; i= Y){ cout << (f(0) == Y ? 0 : -1) << endl; return 0; } ull l=0, r=1e14, c; while(r-l>1){ c = (l+r)/2; if (f(c) >= Y) r=c; else l=c; } cout << (f(r) == Y ? (ll)r : -1) << endl; return 0; }