def max_polygons(N, X, A): left = 0 total = 0 max_total = 0 for right in range(N): total += A[right] while total > X: total -= A[left] left += 1 max_total = max(max_total, total) return max_total #スライディングウィンドウ N, X = map(int, input().split()) A = list(map(int, input().split())) print(max_polygons(N, X, A))