#include using namespace std; using ll =long long; #define all(v) v.begin(),v.end() #define rep(i,a,b) for(int i=a;i=b;i--) ll INF=2e18; int main() { ios::sync_with_stdio(false); cin.tie(0); ll N,X;cin>>N>>X; vector A(2*N); for(ll i=0;i>A[i]; for(ll i=N;i<2*N;i++) { A[i]=A[i%N]; } vector r(2*N+1); for(ll i=1;i<=2*N;i++) { r[i]=r[i-1]+A[i-1]; } ll ans=0; for(ll i=1;i<=N;i++) { ll ma=r[i-1]+X; ll ind=lower_bound(all(r),ma+1)-r.begin(); ind--; ans=max(ans,r[ind]-r[i-1]); } cout<