#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n, m;
long long c[N], a[N];
long long pay[N];
inline long long solve(int d) {
  a[n] = min(c[n], 1LL * d * m - 1LL * d * (d - 1) / 2 * n);
  for (int i = n - 1; i > 0; i--) {
    a[i] = min(c[i], a[i + 1] - d);
    if (a[i] < i * d + d * (d - 1) / 2 * n) return 0;
  }
  int fi = 1;
  int shift = m - (fi - 1) - n * d;
  if (shift < 0) return 0;
  long long sum = pay[1] = a[1];
  for (int i = 2; i <= n; i++) {
    pay[i] = pay[i - 1] + d;
    int mini = min(1LL * shift, a[i] - pay[i]);
    shift -= mini;
    pay[i] += mini;
    sum += pay[i];
  }
  return sum;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%I64d", c + i);
  long long ans = 0;
  for (int d = 1; d <= m / n; d++) ans = max(ans, solve(d));
  printf("%I64d\n", ans);
  return 0;
}
