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>
template <typename T>
using duo = std::pair<T, T>;
template <typename T>
using vec = std::vector<T>;
using ll = long long;
template <typename T, typename U>
inline bool chmax(T& x, U a) {
  return x < a && (x = a, 1);
}
template <typename T, typename U>
inline bool chmin(T& x, U a) {
  return a < x && (x = a, 1);
}
template <typename T = int>
inline T in() {
  T x;
  std::cin >> x;
  return x;
}
template <typename T = int>
inline vec<T> in(int n) {
  vec<T> v;
  v.reserve(n);
  for (int i = (0); i < (int)(n); ++i) v.emplace_back(in<T>());
  return v;
}
template <typename T>
vec<T> ndvec(T v, int n) {
  return vec<T>(n, v);
}
template <typename T, typename... Ts>
auto ndvec(T v, int n, Ts... ns) -> vec<decltype(ndvec(v, ns...))> {
  return ndvec(ndvec(v, ns...), n);
}
template <typename T>
inline void pr(T x) {
  std::cout << x << '\n';
}
template <typename T, typename... Ts>
inline void pr(T x, Ts... xs) {
  std::cout << x << ' ';
  pr(xs...);
}
inline int rd() {
  int x = 0, m = 0, k;
  for (;;) {
    (k) = getchar_unlocked();
    if (k == '-') {
      m = 1;
      break;
    }
    if ('0' <= k && k <= '9') {
      x = k - '0';
      break;
    }
  }
  for (;;) {
    (k) = getchar_unlocked();
    if (k < '0' || '9' < k) break;
    x = x * 10 + k - '0';
  }
  return x;
}
inline void wr(int x, char c = '\n') {
  int s = 0, m = 0;
  char b[32];
  if (x < 0) m = 1, x = -x;
  for (; x; x /= 10) b[s++] = x % 10;
  if (!s) b[s++] = 0;
  if (m) putchar_unlocked('-');
  for (; s--;) putchar_unlocked(b[s] + '0');
  putchar_unlocked(c);
}
struct IoSetup {
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup;
using namespace std;
const int inf = 1001001001;
const ll infll = LLONG_MAX;
const int dd[] = {0, 1, 0, -1, 0};
signed main() {
  ll N = in(), x = in();
  auto A = in<ll>(N);
  auto dp = ndvec(duo<ll>(infll, infll), N, N * 2);
  for (int i = (0); i < (int)(N); ++i) {
    dp[i][0] = duo<ll>(A[i], A[i]);
    for (int j = (1); j < (int)(N * 2); ++j) {
      dp[i][j] =
          min(make_pair(j * x + A[(i + N - j % N) % N], A[(i + N - j % N) % N]),
              dp[i][j - 1]);
    }
  }
  ll mini = infll;
  for (int slide = (0); slide < (int)(N * 2); ++slide) {
    ll cost = 0;
    for (int i = (0); i < (int)(N); ++i) cost += dp[i][slide].second;
    chmin(mini, cost + slide * x);
  }
  pr(mini);
  return 0;
}
