N, X = map(int, input().split()) A = list(map(int, input().split())) A += A j = 0 ans = 0 tmp = 0 for i in range(N): while j < i + N and tmp + A[j] <= X: tmp += A[j] j += 1 ans = max(ans, tmp) tmp -= A[i] print(ans)