#include #define rep(i,n) for(int i=0; i< (n); i++) using namespace std; typedef long long ll; typedef pair P; const int mod = 998244353; const int inf = (1<<30); const ll INF = (1ull<<62); bool check(vector a, int x){ ll k = 0; int n = a.size(); rep(i,n){ if(a[i] > x) k += a[i]-x; else if(a[i] < x){ if(x-a[i] > k) return 0; k += a[i] - x; } if(k < 0) return 0; } return 1; } int binary(vector a){ int l = 0, r = 1e+9 + 5; while(l < r){ int mid = (l+r+1)/2; if(check(a,mid)) l = mid; else r = mid-1; } return l; } int main(){ int n,m; cin>>n>>m; vector a(n); rep(i,n) cin>>a[i]; cout<