#include <bits/stdc++.h>
long long sum(long long val) {
  if (val % 2) return (val + 1) / 2 * val;
  return val / 2 * (val + 1);
}
int main() {
  long long n, x, d[200005], i, xx, l, ans = 0, now, tmp;
  scanf("%lld%lld", &n, &x);
  for (i = 0; i < n; i++) scanf("%lld", &d[i]);
  l = n - 1;
  xx = x;
  now = 0;
  for (i = n - 1; i >= 0; i--) {
    while (xx >= d[l]) {
      xx -= d[l];
      now += sum(d[l]);
      l--;
      if (l < 0) l += n;
    }
    tmp = now - sum(d[l] - xx) + sum(d[l]);
    if (tmp > ans) ans = tmp;
    xx += d[i];
    now -= sum(d[i]);
  }
  printf("%lld\n", ans);
  return 0;
}
