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;
struct items {
  long long minv, numm, org;
};
static const long long MAX = 2001;
items dp[MAX] = {};
int main() {
  long long n, x;
  cin >> n >> x;
  vector<long long> a;
  for (long long i = 0; i < n; i++) {
    long long p;
    cin >> p;
    a.push_back(p);
    dp[i].minv = p;
    dp[i].numm = 0;
    dp[i].org = p;
  }
  for (long long itr = 0; itr < 2; itr++) {
    for (long long i = 0; i < n; i++) {
      dp[i + 1].minv = min(dp[i].minv + x, a[i + 1]);
      if (dp[i + 1].minv == a[i + 1]) {
        dp[i + 1].numm = 0;
        dp[i + 1].org = i + 1;
      } else {
        dp[i + 1].numm = dp[i].numm + 1;
        dp[i + 1].org = dp[i].org;
      }
    }
    dp[0].minv = min(dp[n - 1].minv + x, a[0]);
    if (dp[0].minv == a[0]) {
      dp[0].numm = 0;
      dp[0].org = 0;
    } else {
      dp[0].numm = dp[n - 1].numm + 1;
      dp[0].org = dp[n - 1].org;
    }
  }
  long long ans = 0;
  long long num_magic = 0;
  for (long long i = 0; i < n; i++) {
    if (num_magic < dp[i].numm) {
      num_magic = dp[i].numm;
    }
  }
  ans += num_magic * x;
  for (long long i = 0; i < n; i++) {
    ans += a[dp[i].org];
  }
  cout << ans << endl;
}
