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;
int main() {
  int n;
  unsigned long long x, a[2001], ans = 0;
  unsigned long long d[2001];
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    pq.push(make_pair(a[i], i));
    d[i] = 1e18;
  }
  while (pq.size()) {
    pair<int, int> u = pq.top();
    pq.pop();
    unsigned long long cost = u.first;
    for (int i = 0; i < n; i++) {
      if (i == u.second) continue;
      if (i < u.second)
        cost = min(cost, (unsigned long long)(u.second - i) * (x + a[i]));
      else
        cost = min(cost, (unsigned long long)(n + u.second - i) * (x + a[i]));
    }
    if (cost == u.first) d[u.second] = u.first;
  }
  unsigned long long mt = 0;
  for (int i = 0; i < n; i++) {
    if (d[i] == 1e18) {
      unsigned long long tmp = 2001 + 1;
      for (int j = 0; j < n; j++) {
        if (d[j] == 1e18 || i == j) continue;
        if (i < j)
          tmp = min(tmp, (unsigned long long)j - i);
        else
          tmp = min(tmp, (unsigned long long)n + j - i);
      }
      mt = max(mt, tmp);
    } else {
      unsigned long long sum = 1;
      for (int j = i + 1;; j++) {
        int index = j % n;
        if (d[index] != 1e18) break;
        sum++;
      }
      ans += sum * a[i];
    }
  }
  ans += mt * x;
  for (int i = 0; i < n; i++) {
    if (d[i] != 1e18) {
      unsigned long long tmp = 0;
      for (int j = 0; j < mt; j++) {
        int index = (i + j + 1) % n;
        if (d[index] != 1e18) tmp = d[index];
        ans -= tmp;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
