N, X = map(int, input().split()) A = list(map(int, input().split())) A += A ans = 0 cnt = 0 right = 0 for left in range(N*2): while right < N*2 and cnt+A[right] <= X and right-left < N: cnt += A[right] right += 1 ans = max(ans, cnt) if left == right: right += 1 continue cnt -= A[left] print(ans)