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>
int min(int a, int b) { return a > b ? b : a; }
long long int minll(long long int a, long long int b) { return a > b ? b : a; }
int a[2000];
int tree[400000], n;
int inf;
void segment_tree() {
  inf = 2000000000;
  long long int i;
  long long int tmp = 1;
  long long int n_ = n;
  while (tmp <= n) {
    tmp *= 2;
  }
  n = tmp;
  for (i = 0; i < n; i++) {
    tree[i + n - 1] = inf;
  }
  for (i = 0; i < n_; i++) {
    tree[i + n - 1] = a[i];
  }
  for (i = n - 2; i >= 0; i--) {
    tree[i] = min(tree[2 * i + 1], tree[2 * i + 2]);
  }
}
int rmq(int a, int b, int k, int l, int r) {
  if (l >= r) {
    r = n;
  }
  if (r <= a || b <= l) {
    return inf;
  }
  if (a <= l && r <= b) {
    return tree[k];
  }
  int vl = rmq(a, b, 2 * k + 1, l, (l + r) / 2);
  int vr = rmq(a, b, 2 * k + 2, (l + r) / 2, r);
  return min(vl, vr);
}
int main(void) {
  int x;
  scanf("%d%d", &n, &x);
  int n_init = n;
  int i, j, k;
  long long int ans;
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  segment_tree();
  long long int Ans = 100000000000001;
  for (i = 0; i < n; i++) {
    ans = i * x;
    for (j = 0; j < n_init; j++) {
      int tmp = 2000000000;
      int tmp1 = inf;
      int tmp2 = inf;
      if (j - i < 0) {
        tmp1 = rmq(0, j + 1, 0, 0, 0);
        tmp2 = rmq(j - i + n_init, n_init, 0, 0, 0);
        tmp = min(tmp1, tmp2);
      } else {
        tmp = rmq(j - i, j + 1, 0, 0, 0);
      }
      ans += tmp;
    }
    Ans = minll(ans, Ans);
  }
  printf("%lld\n", Ans);
}
