#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 5;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
long long a[maxN], b[maxN], ans = 0;
int main() {
  time_t START = clock();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%lld", a + i);
  for (int k = 1; k * n <= m; k++) {
    b[n - 1] = min(a[n - 1], 1ll * k * m - 1ll * n * k * (k - 1) / 2);
    for (int i = n - 2; i > -1; i--) b[i] = min(a[i], b[i + 1] - k);
    if (b[0] < (1ll * k * (k - 1) / 2 * n + k)) continue;
    int empty = m - k * n;
    long long minsum = b[0], tmp = b[0];
    for (int i = 1; i < n; i++) {
      long long arumin = min(0ll + empty, b[i] - minsum - k);
      minsum += arumin + k;
      empty -= arumin;
      tmp += minsum;
    }
    ans = max(ans, tmp);
  }
  printf("%lld\n", ans);
  time_t FINISH = clock();
  cerr << "Execution time: "
       << (long double)(FINISH - START) / CLOCKS_PER_SEC * 1000.0
       << " milliseconds.\n";
  return 0;
}
