#include <bits/stdc++.h>
using namespace std;
const int max_n = 2e5 + 5;
long long money[max_n];
long long a[max_n];
long long n, m;
long long find_a(long long k) {
  long long id = (k - 1) * (m - n + 1) - (k - 1) * (k - 2) / 2;
  return max(a[0] - id, 1LL * 1);
}
long long solve(long long k) {
  a[n - 1] = min(money[n - 1], k * m - (n * (k * (k - 1)) / 2));
  for (int i = n - 2; i >= 0; i--) a[i] = min(money[i], a[i + 1] - k);
  if (a[0] <= 0) return 0;
  long long fc = find_a(k);
  long long ans = a[0];
  long long spc = m - fc - n * k + 1;
  long long index = a[0];
  for (int i = 1; i < n; i++) {
    long long id = min(spc, a[i] - index - k);
    spc = max(1LL * 0, spc - id);
    index = index + k + id;
    ans += index;
  }
  return ans;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> money[i];
  long long ans = 0;
  long long max_k = m / n;
  for (int k = 1; k <= max_k; k++) ans = max(ans, solve(k));
  cout << ans;
}
