#include void solve() { int n, x; std::cin >> n >> x; std::vector a(n); for (int i = 0; i < n; i++) std::cin >> a[i]; for (int i = 0; i < n; i++) { a.push_back(a[i]); } int r = 0; int sum = 0; int ans = 0; for (int l = 0; l < n; l++) { if (r < l) r = l; while (r < 2 * n && sum + a[r] <= x) { sum += a[r]; r++; } ans = std::max(ans, sum); if (l < r) { sum -= a[l]; } } std::cout << ans << '\n'; } int main() { std::cin.tie(0)->sync_with_stdio(0); std::cout << std::fixed << std::setprecision(16); int t = 1; while (t--) solve(); }