#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n,x; cin >> n >> x; vector A(2*n); for (int i = 0; i < n; i++){ cin >> A[i]; A[i+n] = A[i]; } int ans = 0; int r=0,count=0; for (int l = 0; l < n; l++){ while (r < 2*n && (r-l) < n) { if (count + A[r] <= x){ count += A[r]; r++; } else{ break; } } ans = max(ans,count); count -= A[l]; } cout << ans << endl; return 0; }