#include <bits/stdc++.h>
using namespace std;
long long a[1001000], ans, p, tt, minn, maxn;
int n, m;
long long work(long long mininter, long long maxinter) {
  long long ans = 0;
  maxn = min(maxn, a[n]);
  for (int i = 1; i <= n - 1; i++)
    if (maxn > a[i] - (i - 1) * mininter + maxinter)
      maxn = min(maxn, a[i] - (i - 1) * mininter + maxinter);
  long long x = maxn;
  for (int i = n; i >= 1; i--) {
    if (i != n) x -= mininter;
    x = min(x, a[i]);
    if (x < minn || maxn - x > maxinter) return -1;
    ans += x;
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  ans = 0;
  for (p = 1; p * n <= m; p++) {
    tt = p * (p - 1) / 2 * n;
    minn = tt + p;
    maxn = m * p - tt;
    ans = max(ans, work(p, m - p));
  }
  printf("%I64d\n", ans);
  return 0;
}
