Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together.

Snuke can perform the following two actions:

* Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds.

* Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds.




Find the minimum time that Snuke needs to have slimes in all N colors.

Constraints

* 2≤N≤2,000
* a_i are integers.
* 1≤a_i≤10^9
* x is an integer.
* 1≤x≤10^9

Input

The input is given from Standard Input in the following format:


N x
a_1 a_2 ... a_N


Output

Find the minimum time that Snuke needs to have slimes in all N colors.

Examples

Input

2 10
1 100


Output

12


Input

3 10
100 1 100


Output

23


Input

4 10
1 2 3 4


Output

10
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
bool prime(long long x) {
  for (long long i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) return false;
  }
  return true;
}
long long kai(long long x) {
  if (x == 1) return 1;
  return kai(x - 1) * x % 1000000007;
}
long long mod_pow(long long x, long long y, long long moder) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x % moder;
    x = x * x % moder;
    y >>= 1;
  }
  return res;
}
long long comb(long long x, long long y) {
  if (y > x) return 0;
  if (x == y) return 1;
  return kai(x) * mod_pow(kai(x - y), 1000000007 - 2, 1000000007) % 1000000007 *
         mod_pow(kai(y), 1000000007 - 2, 1000000007) % 1000000007;
}
long long n, x, a[2000];
long long ta[2000];
signed main() {
  cin >> n >> x;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = n; i < 2 * n; i++) {
    long long cnt = 1145141919364364;
    long long k = 0;
    for (long long j = i; j > i - n; j--) {
      if (cnt > a[j % n] + x * (j - i)) {
        cnt = a[j % n] + x * (j - i);
        k = j % n;
      }
    }
    ta[k]++;
  }
  long long ma = 0;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    ma = max(ma, ta[i] - 1);
    ans += a[i] * ta[i];
  }
  ans += ma * x;
  cout << ans << endl;
}
