#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 69;
long long n, x;
vector<long long> ve, pre, pra;
long long hug(long long a) { return a * (a + 1) / 2; }
long long hugLastDays(long long a, long long days) {
  return days * (2 * a - days + 1) / 2;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n >> x;
  for (int i = 1; i <= n; i++) {
    long long t;
    cin >> t;
    ve.push_back(t);
  }
  reverse(ve.begin(), ve.end());
  pre.assign(n + 1, 0);
  pra.assign(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] + ve[i - 1];
    pra[i] = pra[i - 1] + hug(ve[i - 1]);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int k = upper_bound(pre.begin(), pre.end(), x + pre[i - 1]) - pre.begin();
    if (k == n + 1) {
      long long hugg = pra[n] - pra[i - 1];
      long long sisa = x - (pre[n] - pre[i - 1]);
      int kk = upper_bound(pre.begin(), pre.end(), sisa) - pre.begin();
      hugg += pra[kk - 1];
      sisa -= pre[kk - 1];
      hugg += hugLastDays(ve[kk - 1], sisa);
      ans = max(ans, hugg);
    } else if (k <= n) {
      long long sisa = x - (pre[k - 1] - pre[i - 1]);
      long long hugg = pra[k - 1] - pra[i - 1];
      hugg += hugLastDays(ve[k - 1], sisa);
      ans = max(ans, hugg);
    }
  }
  cout << ans << "\n";
}
