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;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using data = pair<ll, ll>;
long mmid(long a, long b, long c) {
  return a < b ? (b < c ? b : max(a, c)) : (b > c ? b : min(a, c));
}
ll modinv(ll a) {
  ll b = 1000000007, u = 1, v = 0, t;
  while (b) {
    t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  return (u + 1000000007) % 1000000007;
}
ll moddevide(ll a, ll b) { return (a * modinv(b)) % 1000000007; }
ll modncr(ll n, ll r) {
  ll i, plus = 1;
  for (i = 0; i < r; i++) {
    plus = (plus * (n - i)) % 1000000007;
    plus = moddevide(plus, i + 1);
  }
  return plus;
}
ll euclidean_gcd(ll a, ll b) {
  if (a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
ll countdigits(ll n) {
  ll ans = 0;
  while (n) {
    n /= 10;
    ans++;
  }
  return ans;
}
ll sumdigits(ll n) {
  ll ans = 0;
  while (n) {
    ans += n % 10;
    n /= 10;
  }
  return ans;
}
void printmap(vector<ll>& a, ll H, ll W) {
  ll i, j;
  for (i = 0; i < H + 2; i++) {
    for (j = 0; j < W + 2; j++) {
      cout << a[i * (W + 2) + j];
    }
    cout << endl;
  }
}
void inputmap(vector<ll>& a, ll H, ll W) {
  ll i, j;
  string ss;
  for (i = 1; i < H + 1; i++) {
    cin >> ss;
    for (j = 1; j < W + 1; j++) {
      if (ss[j - 1] == '#') {
        a[i * (W + 2) + j] = 1;
      } else {
        a[i * (W + 2) + j] = 0;
      }
    }
  }
}
typedef struct unionfind {
  vector<int> par, treesize;
  unionfind(int N) : par(N) {
    for (int i = 0; i < N; i++) par[i] = i;
    treesize.resize(N);
    for (int i = 0; i < N; i++) treesize[i] = 1;
  }
  int root(int x) {
    int r;
    if (par[x] == x) return x;
    r = root(par[x]);
    if (par[x] != r) {
      treesize[r] += treesize[x];
      treesize[x] = 0;
      par[x] = r;
    }
    return r;
  }
  void unite(int x, int y) {
    int px = root(x);
    int py = root(y);
    if (px != py) {
      par[px] = py;
      treesize[py] += treesize[px];
      treesize[px] = 0;
    }
  }
  bool parcheck(int x, int y) {
    int px = root(x);
    int py = root(y);
    return px == py;
  }
  int size(int x) {
    int px = root(x);
    return treesize[px];
  }
};
int main() {
  ll i, j, N, M, x, tr = 0;
  cin >> N >> x;
  vec a(N), ans(N, 0), mans(N, 100000000000);
  unionfind tree(N);
  for (i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (j = 0; j < N; j++) {
    if (a[0] >= a[N - 1] + x) {
      a[0] = a[N - 1] + x;
      tree.unite(0, N - 1);
    }
    for (i = 1; i < N; i++) {
      if (a[i] >= a[i - 1] + x) {
        a[i] = a[i - 1] + x;
        tree.unite(i, i - 1);
      }
    }
  }
  x = 0;
  for (i = 0; i < N; i++) {
    ans[tree.root(i)] = max(ans[tree.root(i)], a[i]);
    mans[tree.root(i)] = min(mans[tree.root(i)], a[i]);
  }
  for (i = 0; i < N; i++) {
    if (ans[i]) tr = max(tr, ans[i] - mans[i]);
  }
  for (i = 0; i < N; i++) {
    if (ans[i]) x = x + mans[i] * ((ll)tree.size(i));
  }
  cout << x + tr << endl;
  return 0;
}
