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;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;
using graph = vector<vector<long long>>;
const long long inf = (1LL << 31) - 1;
const long long MOD = 1000000007;
struct SegmentTree {
  int n;
  vector<long long> node;

 public:
  SegmentTree(vector<long long> v) {
    int sz = v.size();
    n = 1;
    while (n < sz) n *= 2;
    node.assign(2 * n - 1, inf);
    for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; i--)
      node[i] = min(node[2 * i + 1], node[2 * i + 2]);
  }
  void update(long long x, long long val) {
    x += (n - 1);
    node[x] = val;
    while (x > 0) {
      x = (x - 1) / 2;
      node[x] = min(node[2 * x + 1], node[2 * x + 2]);
    }
  }
  int getmin(long long a, long long b, long long k = 0, long long l = 0,
             long long r = -1) {
    if (r < 0) r = n;
    if (r <= a || b <= l) return inf;
    if (a <= l && r <= b) return node[k];
    long long vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
    long long vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
};
int main() {
  long long n, x;
  cin >> n >> x;
  vector<long long> v(2 * n);
  long long min = INF;
  long long memo;
  for (int i = (0); i < (n); i++) {
    cin >> v[i];
    if (min > v[i]) {
      min = v[i];
      memo = i;
    }
    v[i + n] = v[i];
  }
  long long ans = 0;
  long long m = 1;
  long long mmax = 0;
  vector<int> V;
  V.push_back(min);
  for (int i = (1); i < (n); i++) {
    if (v[memo + i] > (v[memo + i - 1] + x)) {
      v[memo + i] = (v[memo + i - 1] + x);
      m++;
    } else {
      V[V.size() - 1] *= m;
      V.push_back(v[memo + i]);
      mmax = max(mmax, m - 1);
      m = 1;
    }
  }
  V[V.size() - 1] *= m;
  mmax = max(mmax, m - 1);
  for (int i = (0); i < (V.size()); i++) {
    ans += V[i];
  }
  ans += x * mmax;
  cout << ans << endl;
  return 0;
}
