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 long long INFL = 1LL << 60;
const int INF = 1 << 30;
long long MOD = 1e9 + 7;
vector<long long> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<long long> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};
long long max(long long a, long long b) { return (a > b) ? a : b; }
long long min(long long a, long long b) { return (a < b) ? a : b; }
long long pow_long(long long x, long long k) {
  long long res = 1;
  while (k > 0) {
    if (k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
long long pow_mod(long long x, long long k) {
  x %= MOD;
  x += MOD;
  x %= MOD;
  long long res = 1;
  while (k > 0) {
    if (k % 2) {
      res *= x;
      res %= MOD;
    }
    x *= x;
    x %= MOD;
    k /= 2;
  }
  return res;
}
long long inverse(long long x) { return pow_mod(x, MOD - 2); };
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; };
const int MAXcomb = 200010;
long long fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAXcomb; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long comb(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * finv[k] % MOD * finv[n - k] % MOD;
}
const long long N_ = (1 << 18);
long long seg[2 * N_ - 1];
void update(long long k, long long x) {
  k += N_ - 1;
  seg[k] = x;
  while (k > 0) {
    k = (k - 1) / 2;
    seg[k] = min(seg[2 * k + 1], seg[2 * k + 2]);
  }
}
long long query(long long x, long long y, long long k, long long left,
                long long right) {
  if (right <= x || y <= left) return INFL;
  if (x <= left && right <= y) return seg[k];
  long long mid = (left + right) / 2;
  long long l = query(x, y, 2 * k + 1, left, mid);
  long long r = query(x, y, 2 * k + 2, mid, right);
  return min(l, r);
}
int main(void) {
  int N, x;
  cin >> N >> x;
  vector<long long> A(N);
  for (long long i = 0; i < (N); i++) cin >> A[i];
  for (long long i = 0; i < (N); i++) update(i, A[i]);
  long long ans = INFL;
  for (int i = 0; i < N; i++) {
    long long res = x * i;
    for (int j = 0; j < N; j++) {
      if (j >= i) {
        res += query(j - i, j + 1, 0, 0, N_);
      } else {
        res +=
            min(query(0, j + 1, 0, 0, N_), query(N + j - i, N + 1, 0, 0, N_));
      }
    }
    ans = min(ans, res);
  }
  cout << ans << endl;
}
