#include <bits/stdc++.h>   using namespace std;   long long cap[200005];   int n, m;   inline long long tri(int n) { return n * (n + 1LL) / 2; }   inline long long arithsum(int a, int d, int n) {     long long ret = a * (long long)n;     ret += tri(n - 1) * d;     return ret;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) {       scanf( %lld , &cap[i]);     }     long long ret = 0;     for (int rep = 1; (rep)*n <= m; rep++) {       long long total = 0;       bool bad = false;       long long currVal = min(arithsum(m, -n, rep), cap[n - 1]);       for (int i = 0; i < n; i++) {         currVal = min(currVal, cap[i] + m - rep * (i + 1));       }       for (int i = n - 1; !bad && i >= 0; i--) {         total += currVal;         if (i > 0) {           long long drop = currVal - cap[i - 1];           if (drop > m - rep) bad = true;           currVal = min(currVal - rep, cap[i - 1]);         }       }       long long lowFirst = arithsum(1, n, rep);       if (!bad && currVal >= lowFirst) {         ret = max(ret, total);       }     }     printf( %lld n , ret);   }   