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