#include <bits/stdc++.h>
using namespace std;
const int MaxN = 2e5 + 224;
int n;
long long a[MaxN], m;
long long calc(long long Amin, long long Bmax, long long mindiff,
               long long maxdiff) {
  Bmax = min(Bmax, a[n - 1]);
  for (int i = 0; i < n - 1; i++)
    Bmax = min(Bmax, a[i] - i * mindiff + maxdiff);
  long long ans = 0;
  long long x = Bmax;
  for (int i = n - 1; i >= 0; i--) {
    if (i != n - 1) x -= mindiff;
    x = min(x, a[i]);
    if (x < Amin || Bmax - x > maxdiff) return -1;
    ans += x;
  }
  return ans;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  long long ans = 0;
  for (long long cnt = 1; cnt * n <= m; cnt++) {
    long long tri = cnt * (cnt - 1) / 2 * n;
    long long Amin = tri + cnt;
    long long Bmax = m * cnt - tri;
    long long mindiff = cnt;
    long long maxdiff = m - cnt;
    long long temp = calc(Amin, Bmax, mindiff, maxdiff);
    ans = max(ans, temp);
  }
  cout << ans << endl;
  return 0;
}
