using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, x) = (c[0], c[1]); var a = NList.ToList(); for (var i = 0; i + 1 < n; ++i) a.Add(a[i]); var r = 0; var sum = 0L; var ans = 0L; for (var l = 0; l < n; ++l) { while (r < a.Count && r - l <= n && sum <= x) { ans = Math.Max(ans, sum); sum += a[r]; ++r; } sum -= a[l]; } WriteLine(ans); } }