#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 200000;
long long allowances[kMaxN + 2];
int main() {
  int n, m;
  cin >> n;
  cin >> m;
  for (int i = 0; i < n; ++i) {
    cin >> allowances[i];
  }
  long long best = 0L;
  for (int packages = 1; packages <= (m / n); ++packages) {
    long long *reduced_money = new long long[n];
    reduced_money[n - 1] = allowances[n - 1];
    for (int i = n - 2; i >= 0; --i) {
      reduced_money[i] = min(allowances[i], reduced_money[i + 1] - packages);
    }
    if (reduced_money[0] <= 0) continue;
    long long lower_bound =
        (long long)packages +
        (long long)n * (long long)packages * (long long)(packages - 1LL) / 2LL;
    if (reduced_money[0] < lower_bound) continue;
    long long upper_bound = (long long)m * (long long)packages -
                            (long long)n * (long long)(packages) *
                                (long long)(packages - 1L) / 2LL -
                            (long long)(n - 1) * (long long)packages;
    long long upper_bound_except_first =
        (long long)m * (long long)(packages - 1LL) -
        (long long)n * (long long)(packages - 1LL) *
            (long long)(packages - 2LL) / 2LL -
        (long long)(n - 1) * (long long)(packages - 1LL);
    long long init = 1LL;
    long long beg_price = 0LL;
    if (reduced_money[0] <= upper_bound_except_first + 1LL) {
      beg_price = reduced_money[0];
    } else {
      init = reduced_money[0] - upper_bound_except_first;
      if (reduced_money[0] > upper_bound) {
        init = m - n * packages + 1LL;
        beg_price = upper_bound;
      } else {
        beg_price = reduced_money[0];
      }
    }
    long long freedom = m - n * packages - (init - 1LL);
    long long result = beg_price;
    for (int i = 1; i < n; ++i) {
      beg_price += (long long)packages;
      long long delta = reduced_money[i] - beg_price;
      delta = min(freedom, delta);
      freedom -= delta;
      beg_price += delta;
      result += beg_price;
    }
    best = max(best, result);
  }
  cout << best << endl;
}
