#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-12;
const double PI = acos(-1.0);
const double ATRconst = PI / 180.0;
const long long mod = 998244353;
long long max_3(long long a, long long b, long long c) {
  if (a > b && a > c) return a;
  if (b > c) return b;
  return c;
}
long long min_3(long long a, long long b, long long c) {
  if (a < b && a < c) return a;
  if (b < c) return b;
  return c;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long qpow(long long a, long long n) {
  long long r = 1;
  while (n) {
    if (n & 1) r = (r * a) % mod;
    n >>= 1;
    a = (a * a) % mod;
  }
  return r;
}
long long d[200050], ar[1000050];
void solve() {
  int n, p;
  long long x, ans = 0, tmp = 0;
  for (int i = 1; i <= 1000000; i++) ar[i] = ar[i - 1] + i;
  cin >> n >> x;
  for (int i = 1; i <= n; i++) cin >> d[i];
  p = n;
  for (int i = n; i >= 1; i--) {
    while (x > 0) {
      x -= d[p];
      tmp += ar[d[p]];
      if (p == 1)
        p = n;
      else
        p--;
    }
    tmp -= (1 - x) * (-x) / 2;
    ans = max(ans, tmp);
    tmp += (1 - x) * (-x) / 2;
    tmp -= ar[d[i]];
    x += d[i];
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
