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;
const int INF = 0x7f7f7f7f;
int BigMod(long long int B, long long int P, long long int M) {
  long long int R = 1;
  while (P > 0) {
    if (P % 2 == 1) R = (R * B) % M;
    P /= 2;
    B = (B * B) % M;
  }
  return (int)R;
}
long long int maxDivide(long long int a, long long int b) {
  while (a % b == 0) a = a / b;
  return a;
}
long long int isUgly(long long int no) {
  no = maxDivide(no, 2);
  no = maxDivide(no, 3);
  no = maxDivide(no, 5);
  return (no == 1) ? 1 : 0;
}
long long int myXOR(long long int x, long long int y) {
  long long int res = 0;
  for (long long int i = 31; i >= 0; i--) {
    bool b1 = x & (1 << i);
    bool b2 = y & (1 << i);
    bool xoredBit = (b1 & b2) ? 0 : (b1 | b2);
    res <<= 1;
    res |= xoredBit;
  }
  return res;
}
long long int ar[2005], ar1[2005];
int main() {
  long long int a, b, c, d, n, m, x, y, s;
  cin >> n >> x;
  c = INF;
  for (long long int i = 1; i <= n; i++) {
    cin >> ar[i];
    if (ar[i] < c) {
      c = ar[i];
      b = i;
    }
  }
  a = 0;
  s = 0;
  while (a != n) {
    if (a == 0) {
      ar1[b] = b;
      s += ar[b];
      a += 1;
    } else {
      for (long long int i = 1; i <= n; i++) {
        if (ar1[i] == 0) {
          d = i - 1;
          if (d == 0) d = n;
          for (long long int j = i; j <= INF; j++) {
            if (ar1[j] == 0) {
              m = j - 1;
              if (m <= 0) m = n;
              if (ar1[m] == 0) {
                continue;
              } else {
                if (ar[ar1[m]] + x > ar[j]) {
                  ar1[j] = j;
                  s += ar[j];
                } else {
                  ar1[j] = ar1[m];
                  s += (ar[ar1[j]] + x);
                }
                a += 1;
              }
              if (a == n) break;
            }
            if (j == d) break;
            if (j == n) j = 0;
            if (a == n) break;
          }
          break;
        }
      }
    }
  }
  cout << s << endl;
  return 0;
}
