#include <bits/stdc++.h>
using namespace std;
void fre() {
  freopen("A.txt", "r", stdin);
  freopen("Ans.txt", "w", stdout);
}
void Fre() { freopen("A.txt", "r", stdin); }
const int mxn = (2e5 + 10) * 2;
long long ar[mxn];
long long psum[mxn];
long long pday[mxn];
int main() {
  long long n, t;
  scanf("%lld %lld", &n, &t);
  for (int i = 1; i <= n; i++) scanf("%lld", &ar[i]), ar[n + i] = ar[i];
  n *= 2;
  reverse(ar + 1, ar + 1 + n);
  for (int i = 1; i <= n; i++) {
    psum[i] = psum[i - 1] + ar[i] * (1 + ar[i]) / 2;
    pday[i] = pday[i - 1] + ar[i];
  }
  long long ans = 0;
  for (int i = 1; i <= n / 2; i++) {
    long long d = (pday[i - 1] + t);
    long long p = upper_bound(pday + i, pday + i + n, d) - pday;
    long long cha = d - pday[p - 1];
    long long res =
        (psum[p - 1] - psum[i - 1]) + cha * (ar[p] + ar[p] - cha + 1) / 2;
    ans = max(ans, res);
  }
  printf("%lld", ans);
  return 0;
}
