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 Mod = 1000000007;
const long long gosenchou = 5000000000000000;
short gh[2][4] = {{0, 0, -1, 1}, {-1, 1, 0, 0}};
struct P {
  long long pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
  long long to;
  long double cost;
};
struct E {
  long long from, to, cost;
};
bool operator<(E a, E b) { return a.cost < b.cost; }
struct H {
  long long x, y;
};
bool operator<(H a, H b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}
bool operator>(H a, H b) {
  if (a.x != b.x) return a.x > b.x;
  return a.y > b.y;
}
bool operator==(H a, H b) { return a.x == b.x && a.y == b.y; }
bool operator!=(H a, H b) { return a.x != b.x || a.y != b.y; }
long long gcm(long long i, long long j) {
  if (i > j) swap(i, j);
  if (i == 0) return j;
  return gcm(j % i, i);
}
long double rad(H a, H b) {
  return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}
long long ari(long long a, long long b, long long c) { return (a + b) * c / 2; }
bool suf(long double a, long double b, long double c, long double d) {
  if (b <= c || d <= a) return 0;
  return 1;
}
long long fact(long long x, long long k) {
  long long sum = 1;
  for (int i = 0; i < k; i++) sum *= (x--);
  return sum;
}
long long mod_pow(long long x, long long n, long long p) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % p;
    x = x * x % p;
    n >>= 1;
  }
  return res;
}
const long long inf = 4523372036854775807;
const long long iinf = 1500000000;
long long n, x, a[2000];
signed main() {
  cin >> n >> x;
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long ans = 0, sum = 0;
  for (long long i = 0; i < n; i++) {
    H res = H{10000000000000, 10000000000000};
    for (long long j = 0; j <= i; j++) {
      if (res.x + x * res.y > a[j] + x * (i - j) ||
          (res.x + x * res.y == a[j] + x * (i - j) && res.y < i - j))
        res.x = a[j], res.y = i - j;
    }
    for (long long j = i; j < n; j++) {
      if (res.x + x * res.y > a[j] + x * (n - j + i) ||
          (res.x + x * res.y == a[j] + x * (n - j + i) && res.y < n - j + i))
        res.x = a[j], res.y = n - j + i;
    }
    ans += res.x;
    sum = max(sum, res.y);
  }
  cout << ans + x * sum << endl;
  getchar();
  getchar();
}
