#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int N, X; cin >> N >> X; vector A(N*2); rep(i, N) { cin >> A[i]; A[i+N] = A[i]; } int poligon = 0; int y = 0; int maxPoligon = 0; rep(i, N) { while (poligon + A[y] <= X && y < i + N) { poligon += A[y]; y++; } maxPoligon = max(poligon, maxPoligon); poligon -= A[i]; } cout << maxPoligon << endl; return 0; }