#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int TESTS = 1;
  while (TESTS--) {
    long long i, n, x;
    cin >> n >> x;
    vector<long long> v(2 * n), pre(2 * n), sum(2 * n);
    for (i = 0; i < n; i++) {
      cin >> v[i];
      v[n + i] = v[i];
      pre[i] = v[i];
      pre[n + i] = pre[i];
      sum[i] = (v[i] * (v[i] + 1)) / 2;
      sum[n + i] = sum[i];
    }
    for (i = 1; i < 2 * n; i++) {
      pre[i] += pre[i - 1];
      sum[i] += sum[i - 1];
    }
    x = pre[n - 1] - x;
    long long r, l, t, ans = LLONG_MAX;
    for (l = 0; l < n; l++) {
      t = 0;
      auto g = upper_bound(pre.begin() + l, pre.end(), pre[l] + x);
      r = g - pre.begin();
      t = sum[r - 1] - sum[l];
      t += ((x - pre[r - 1] + pre[l]) * (x - pre[r - 1] + pre[l] + 1)) / 2;
      ans = min(ans, t);
    }
    cout << sum[n - 1] - ans << endl;
  }
}
