#include <bits/stdc++.h>
using namespace std;
signed main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, x;
  cin >> n >> x;
  vector<long long> d(2 * n);
  for (long long i = 0; i < n; i++) {
    cin >> d[i];
    d[i + n] = d[i];
  }
  vector<long long> ph(2 * n), pd(2 * n);
  for (long long i = 0; i < 2 * n; i++) {
    ph[i] = i == 0 ? d[i] * (d[i] + 1) / 2 : ph[i - 1] + d[i] * (d[i] + 1) / 2;
    pd[i] = i == 0 ? d[i] : pd[i - 1] + d[i];
  }
  long long ans = 0;
  for (long long i = n; i < 2 * n; i++) {
    long long idx = upper_bound(pd.begin(), pd.end(), pd[i] - x) - pd.begin();
    long long hugs = ph[i] - ph[idx];
    long long days_left = x - (pd[i] - pd[idx]);
    hugs += (long long)(2 * d[idx] - days_left + 1) * (long long)days_left / 2;
    ans = max(ans, hugs);
  }
  cout << ans << "\n";
}
