#include <bits/stdc++.h>
using namespace std;
long long i, j, k, n, m, an;
long long a[200010];
inline long long work(long long A, long long B, long long C) {
  long long i;
  long long re = m * k - A, an = 0;
  re = min(re, a[n]);
  for (i = 1; i <= n; i++) re = min(re, a[i] - (i - 1) * k + C);
  for (i = n; i; i--) {
    if (i < n) re -= k;
    re = min(re, a[i]);
    if (i == 1 && re < B) return -1;
    an += re;
  }
  return an;
}
int main() {
  scanf("%I64d%I64d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  for (k = 1; k * n <= m; k++) {
    long long A = k * (k - 1) / 2 * n;
    long long B = A + k;
    an = max(an, work(A, B, m - k));
  }
  printf("%I64d\n", an);
  return 0;
}
