import sys input = sys.stdin.readline def read_values(): return tuple(map(int, input().split())) def read_list(): return list(map(int, input().split())) def main(): n,x=read_values() a=read_list() ans=0 a=a+a l=0 t=0 for i in range(n*2): t+=a[i] while t>x or i-l>=n: t-=a[l] l+=1 ans=max(ans,t) print(ans) if __name__ == "__main__": main()