#include using namespace std; /* --- ACL --- */ #if __has_include() #include #endif /* --- PBDS, reference: https://codeforces.com/blog/entry/11080 --- */ #include #include using namespace __gnu_pbds; template using IndexSet=tree,rb_tree_tag,tree_order_statistics_node_update>; template using IndexMultiset=tree,rb_tree_tag,tree_order_statistics_node_update>; /* --- CUSTOM HASH, reference: https://codeforces.com/blog/entry/62393 --- */ struct MyHash { static uint64_t splitmix64(uint64_t x){x+=0x9e3779b97f4a7c15;x=(x^(x>>30))*0xbf58476d1ce4e5b9;x=(x^(x>>27))*0x94d049bb133111eb;return x^(x>>31);} size_t operator()(uint64_t x) const{static const uint64_t FIXED_RANDOM=chrono::steady_clock::now().time_since_epoch().count();return splitmix64(x+FIXED_RANDOM);} }; template using us=unordered_set;template using um=unordered_map; using ll=long long;using ull=unsigned long long;using ld=long double; const int MOD=1000000007; // const int MOD=998244353; const ll NX[]{+0,+1,+0,-1,+1,+1,-1,-1}; const ll NY[]{+1,+0,-1,+0,+1,-1,-1,+1}; const ll INF64=0x1fffffffffffffff; template using v=vector;template using vv=v>;template using vvv=v>; using vl=v;using vvl=vv;using vi=v;using vvi=vv;using vs=v; using vb=v;using vd=v;using pl=pair;using vp=v;using pd=pair;using vpd=v; template using pqg=priority_queue,greater>; #define overload3(a, b, c, name, ...) name #define rep1(n) for(ll i=0;i(a);) #define rrep(...) overload3(__VA_ARGS__,rrep3,rrep2,rrep1)(__VA_ARGS__) #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define sum(...) accumulate(all(__VA_ARGS__),0LL) #define CASE ll _t; cin >> _t; while (_t--) #define YESNO(yes,no)void yes(bool i=1){cout<<(i?#yes:#no)<<'\n';}void no(){cout<<(#no)<<'\n';} YESNO(first,second)YESNO(First,Second)YESNO(Yes,No)YESNO(YES,NO)YESNO(possible,impossible)YESNO(POSSIBLE,IMPOSSIBLE) vector iota(ll n,ll begin=0){vectora(n);iota(all(a),begin);return a;} vector divisors(ull x){vectorans;for(ull i=1;i*i<=x;i++)if(x%i==0){ans.push_back(i);}for(int i=(ans.size()-(ans.back()*ans.back()==x));i--;){ans.push_back(x/ans[i]);}return ans;} vector factorize(ull x){vectorans;for(ull i=2;i*i<=x;i++)if(x%i==0){ans.push_back({i,1});while((x/=i)%i==0)ans.back().second++;}if(x!=1)ans.push_back({x,1});return ans;} ll intpow(ll a,ll b){ll ans=1;while(b){if(b&1)ans*=a;a*=a;b/=2;}return ans;}ll intpow(ll a,ll b,ll p){ll ans=1;while(b){if(b&1)(ans*=a)%=p;(a*=a)%=p;b/=2;}return ans;} ll popcnt(ull a){return __builtin_popcountll(a);} templatevoid distinct(T&a){sort(all(a));a.erase(unique(all(a)),end(a));} templatevoid filter(T&a,F b){a.erase(remove_if(all(a),not_fn(b)),a.end());} templatebool chmin(T&a,const T&b){if(a<=b)return 0;a=b;return 1;}templatebool chmin(T&a,const U&b){return chmin(a,(T)b);} templatebool chmax(T&a,const T&b){if(a>=b)return 0;a=b;return 1;}templatebool chmax(T&a,const U&b){return chmax(a,(T)b);} templateostream&operator<<(ostream&os,pair&p){os<istream&operator>>(istream&is,pair&p){is>>p.first>>p.second;return is;} templateostream&operator<<(ostream&os,vector&v){for(auto it=v.begin();it!=v.end();){os<<*it<<((++it)!=v.end()?" ":"");}return os;} templateistream&operator>>(istream&is,vector&v){for(T&e:v)is>>e;return is;} struct Nyan{Nyan(){cin.tie(nullptr)->sync_with_stdio(0);fixed(cout).precision(12);}}NYAAN; //////////////////////////// SOLVING BEGIN //////////////////////////// template T bisearch(T s, T e, F f) { T L = s, R = e; T ret = L; while (L <= R) { T M = L + (R - L) / 2; if (f(M)) { ret = M; L = M + 1; } else { R = M - 1; } } return ret; } signed main() { ll n, k; cin >> n >> k; vl a(n); cin >> a; auto chk = [&](ll x) -> bool { ll add = 0; ll cnt = 0; rep(n) if (a[i] + add < x) { ll cost = (x - (a[i] + add) + i) / (i + 1); cnt += cost; if (cnt > k) return false; add += cost * (i + 1); } return true; }; cout << bisearch(0LL, intpow(10, 16), chk) << '\n'; }