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;
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool d = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') d = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return d ? x : -x;
}
inline void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar('0' + x % 10);
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
inline void writep(long long x) {
  write(x);
  putchar(' ');
}
inline unsigned long long rnd() {
  return ((unsigned long long)rand() << 30 ^ rand()) << 4 | rand() % 4;
}
const int N = 2005;
const long long inf = 1e14;
int n, x, b[N];
long long f[2][N][N];
struct info {
  int op, x, y;
} a[N][N];
void MN(long long &x, long long y) {
  if (y < x) x = y;
}
void upd(int len, int i, int j) {
  MN(f[a[len][j].op][a[len][j].x][a[len][j].y],
     f[a[len][i].op][a[len][i].x][a[len][i].y] + x);
}
void solve(int len) {
  int pos = 1;
  long long mn = inf;
  for (int i = (int)(1); i <= (int)(n); i++) {
    bool d = 0;
    int j = i + len - 1;
    if (j > n) j -= n, d = 1;
    if (f[d][i][j] < mn) mn = f[d][i][j], pos = i;
  }
  for (int i = (int)(pos); i <= (int)(n - 1); i++) upd(len, i, i + 1);
  upd(len, n, 1);
  for (int i = (int)(1); i <= (int)(pos - 1); i++) upd(len, i, i + 1);
}
int main() {
  n = read();
  x = read();
  for (int i = (int)(1); i <= (int)(n); i++) b[i] = read();
  for (int i = (int)(0); i <= (int)(1); i++)
    for (int j = (int)(0); j <= (int)(n); j++)
      for (int k = (int)(0); k <= (int)(n); k++) f[i][j][k] = inf;
  for (int i = (int)(1); i <= (int)(n); i++) {
    f[0][i][i] = b[i];
    a[1][i] = (info){0, i, i};
  }
  solve(1);
  for (int len = (int)(2); len <= (int)(n); len++) {
    for (int i = (int)(1); i <= (int)(n); i++) {
      bool d = 0;
      int j = i + len - 1;
      if (j > n) j -= n, d = 1;
      a[len][i] = (info){d, i, j};
      MN(f[d][i][j],
         f[a[len - 1][i].op][a[len - 1][i].x][a[len - 1][i].y] + b[j]);
      int to = i + 1;
      if (i == n) to = 1;
      MN(f[d][i][j],
         f[a[len - 1][to].op][a[len - 1][to].x][a[len - 1][to].y] + b[i]);
    }
    solve(len);
  }
  long long ans = inf;
  for (int i = (int)(1); i <= (int)(n); i++)
    MN(ans, f[a[n][i].op][a[n][i].x][a[n][i].y]);
  cout << ans;
}
