#include <bits/stdc++.h>
using namespace std;
long long n, x, a[200005 * 3], yr, sum[200005 * 3], sum2[200005 * 3], ans;
void work(long long i, long long t) {
  long long ret = 0;
  if (sum2[i - 1] + t > 2 * yr) ret += sum[n] * (t / yr), t %= yr;
  long long tar = upper_bound(sum + 1, sum + 1 + 3 * n, sum[i - 1] + t) - sum;
  if (tar != i) {
    ret += sum2[tar - 1] - sum2[i];
    t -= sum[tar - 1] - sum[i];
    long long l = t - a[tar];
    l = a[i] - l;
    if (a[tar] >= a[i] && t <= a[tar])
      ret += (t * (t + 1) / 2);
    else
      ret += (a[tar] * (a[tar] + 1) / 2),
          ret += a[i] * (a[i] + 1) / 2 - l * (l + 1) / 2;
  } else
    ret += a[i] * (a[i] + 1) / 2 - (a[i] - t) * (a[i] - t + 1) / 2;
  ans = max(ans, ret);
}
int main() {
  cin >> n >> x;
  for (int i = 1; i <= n; i += 1)
    cin >> a[i], a[i + n] = a[i], a[i + n + n] = a[i], yr += a[i];
  for (int i = 1; i <= 3 * n; i += 1)
    sum2[i] = sum2[i - 1] + a[i] * (a[i] + 1) / 2, sum[i] = sum[i - 1] + a[i];
  for (int i = 1; i <= n; i += 1) {
    work(i, x);
  }
  cout << ans << endl;
  return 0;
}
