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 <typename T>
using Vec = vector<T>;
template <typename T>
using Matrix = Vec<Vec<T> >;
template <typename T>
using USet = unordered_set<T>;
template <typename T, class C>
using MyUSet = unordered_set<T, C>;
template <typename T, typename F>
using UMap = unordered_map<T, F>;
template <typename T, typename F, class C>
using MyUMap = unordered_map<T, F, C>;
class PiiHash {
 public:
  size_t operator()(const pair<int, int>& p) const {
    return (p.first << 16) | p.second;
  }
};
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(long long x) { return __builtin_popcount(x); }
const int iINF = 1L << 30;
const long long lINF = 1LL << 60;
const double EPS = 1e-9;
const double PI = acos(-1);
template <typename T>
inline bool in_range(T v, T mi, T mx) {
  return mi <= v && v < mx;
}
template <typename T>
inline bool in_range(T x, T y, T W, T H) {
  return in_range(x, 0, W) && in_range(y, 0, H);
}
const int DX[4] = {0, 1, 0, -1}, DY[4] = {-1, 0, 1, 0};
const int DX_[8] = {0, 1, 1, 1, 0, -1, -1, -1},
          DY_[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
template <typename T>
inline void modAdd(T& a, T b, T mod) {
  a = (a + b) % mod;
}
template <typename T>
inline void minUpdate(T& a, T b) {
  a = min(a, b);
}
template <typename T>
inline void maxUpdate(T& a, T b) {
  a = max(a, b);
}
template <typename F, typename T>
inline void convert(F& from, T& to) {
  stringstream ss;
  ss << from;
  ss >> to;
}
int N;
long long x, a[2020];
int main() {
  cin >> N >> x;
  for (int i = (0); i < (N); ++i) cin >> a[i];
  long long ans = 0, max_k = 0;
  for (int i = (0); i < (N); ++i) {
    auto next = [&](int j) { return (j - 1 + N) % N; };
    long long max_sub = -1, select_k = 0;
    int cur = next(i), k = 1, select = i;
    while (cur != i) {
      int sub = a[i] - (a[cur] + k * x);
      if (max_sub < sub) {
        max_sub = sub;
        select = cur;
        select_k = k;
      }
      ++k;
      cur = next(cur);
    }
    ans += a[select];
    max_k = max(max_k, select_k);
  }
  ans += max_k * x;
  cout << ans << endl;
}
