#include <bits/stdc++.h>
using namespace std;
int N, M;
long long A[200002];
long long B[200002];
long long result;
int main() {
  cin.sync_with_stdio(false);
  cin >> N >> M;
  for (int i = 1; i <= N; ++i) cin >> A[i];
  for (int i = 1; i <= M / N; ++i) {
    B[N] = min(1LL * i * M - 1LL * N * i * (i - 1) / 2, A[N]);
    for (int j = N - 1; j >= 1; --j) B[j] = min(B[j + 1] - i, A[j]);
    bool anywrong = false;
    for (int j = 1; j <= N; ++j)
      if (B[j] < 1LL * j * i + 1LL * N * i * (i - 1) / 2) {
        anywrong = true;
        break;
      }
    if (anywrong) continue;
    long long diff = (1LL * i * (M + 1) - 1LL * N * i * (i + 1) / 2) - B[1],
              freedom;
    if (diff >= (M + 1) - i * N - 1)
      freedom = (M + 1) - i * N - 1;
    else
      freedom = diff;
    long long resultnow = B[1], lastsum = B[1];
    for (int j = 2; j <= N; ++j) {
      long long minimum = lastsum + i;
      long long shift = min(B[j] - minimum, 1LL * freedom);
      resultnow += minimum + shift;
      freedom -= shift;
      lastsum = minimum + shift;
    }
    result = max(result, resultnow);
  }
  cout << result << '\n';
}
