#include <bits/stdc++.h>
using namespace std;
long long n, x, d[400003];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> x;
  long long pre[2 * n + 1];
  pre[0] = 0;
  long long days[2 * n + 1];
  days[0] = 0;
  long long total = 0;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    total += d[i];
    d[i + n] = d[i];
    if (i == 1) {
      pre[i] = d[i] * (d[i] + 1) / 2;
      days[i] = d[i];
    } else {
      pre[i] = pre[i - 1] + d[i] * (d[i] + 1) / 2;
      days[i] = days[i - 1] + d[i];
    }
  }
  for (int i = n + 1; i <= 2 * n; i++) {
    pre[i] = pre[i - 1] + d[i % (n + 1) + 1] * (d[i % (n + 1) + 1] + 1) / 2;
    days[i] = days[i - 1] + d[i % (n + 1) + 1];
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long avail = x % total;
    if (avail <= d[i]) {
      ans = max(ans, x / total * pre[n] + avail * (2 * d[i] - avail + 1) / 2);
      continue;
    }
    int beg = i, en = i + n - 1;
    int idx = i;
    while (beg <= en) {
      int mid = (beg + en) / 2;
      if (days[mid] - days[i - 1] > x) {
        en = mid - 1;
      } else {
        idx = mid;
        beg = mid + 1;
      }
    }
    long long rem = avail - (days[idx] - days[i - 1]);
    long long y = d[idx + 1];
    long long z = y - rem;
    long long curr = x / total * pre[n] + pre[idx] - pre[i - 1];
    if (z > d[i]) {
      curr += -d[i] * (d[i] + 1) / 2 + (rem + d[i]) * (rem + d[i] + 1) / 2;
    } else {
      curr += -z * (z + 1) / 2 + y * (y + 1) / 2;
    }
    ans = max(ans, curr);
  }
  cout << ans;
}
