#include #include using namespace std; using ll = long long; using namespace boost::multiprecision; using ull = cpp_int; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); /* clamp関数は広義単調 f(x)>=Yを満たす最小のxが答えになりうる。 */ ll N, Y; ull 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=(ll)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; }