#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
long long a[MAXN];
long long b[MAXN];
int n, m;
long long c2(long long x) { return (x * (x - 1)) / 2; }
long long f(int l) {
  if (m < l * n) {
    return -1;
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] < i * l + n * c2(l)) {
      return -1;
    }
    b[i] = a[i] - (i * l + n * c2(l));
  }
  long long res = 0, f = m;
  for (int i = l; i >= 1; i--) {
    for (int j = n; j >= 1; j--) {
      b[j] += j + (i - 1) * n;
      if (b[j] >= f) {
        res += f;
        b[j] -= f;
        f--;
      } else {
        res += b[j];
        f = b[j] - 1;
        b[j] = 0;
      }
    }
  }
  return res;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int L = 1, R = (m / n) + 1;
  while (R - L > 5) {
    int mid = (L + R) / 2;
    if (f(mid) < f(mid + 1)) {
      L = mid;
    } else {
      R = mid;
    }
  }
  long long res = 0;
  for (int i = L; i <= R; i++) {
    res = max(res, f(i));
  }
  cout << res;
}
