#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
int n, m;
long long sol, a[MAXN], b[MAXN];
int main(void) {
  scanf("%d %d", &n, &m);
  for (int i = (0); i < (n); ++i) cin >> b[i];
  for (int r = 1; r * n <= m; ++r) {
    for (int i = (0); i < (n); ++i) a[i] = b[i];
    for (int i = n - 2; i >= 0; --i) a[i] = min(a[i], a[i + 1] - r);
    long long first =
        min(a[0], (long long)r * m - (long long)n * r * (r + 1) / 2 + r);
    long long min_first = r + (long long)n * r * (r - 1) / 2;
    if (min_first > a[0]) continue;
    int pos = -1, lo = 1, hi = m + 1 - n * r;
    while (lo <= hi) {
      int mid = (lo + hi) / 2;
      long long candies = min(a[0], mid + (long long)(r - 1) * m -
                                        (long long)n * r * (r - 1) / 2 + r - 1);
      if (candies == first) {
        pos = mid;
        hi = mid - 1;
      } else
        lo = mid + 1;
    }
    if (pos == -1) continue;
    long long fr = m - n * r - (pos - 1);
    long long tmp = first;
    a[0] = first;
    for (int i = (1); i < (n); ++i) {
      long long t = min(a[i], a[i - 1] + r + fr);
      a[i] = t;
      tmp += t;
      fr -= t - (a[i - 1] + r);
    }
    if (tmp > sol) {
      sol = tmp;
    }
  }
  cout << sol << endl;
  return 0;
}
