#include #include #include #include #include #include #include #include #include #include #include #include #include #define int long long using namespace std; #define all(x) (x).begin(),(x).end() #define rep(i,n) for (int i=0;i<(n);++i) #define prep(i,n) for (int i=1;i<=(n);++i) #define ep(i,j,n) for (int i=j+1;i<=(n);++i) int INF = 900000000000000; int mod=998244353; signed main(){ int n,x;cin>>n>>x; int m=0; int a[2*n]; int b[2*n+10];b[0]=0; rep(i,n){cin>>a[i];m+=a[i];} rep(i,n){a[i+n]=a[i];} rep(i,2*n){b[i+1]=b[i]+a[i];} int ans=0; rep(i,n){ int pos=lower_bound(b,b+2*n,m-x+b[i])-b; if(pos-i>=n){continue;} ans=max(ans,m+b[i]-b[pos]); // if(m-b[pos]-b[i]==9){cout<