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 void YES(T condition) {
  if (condition)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
template <class T>
inline void Yes(T condition) {
  if (condition)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
template <class T>
inline void POSS(T condition) {
  if (condition)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;
}
template <class T>
inline void Poss(T condition) {
  if (condition)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
}
template <class T>
inline void First(T condition) {
  if (condition)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}
template <class T = string, class U = char>
int character_count(T text, U character) {
  int ans = 0;
  for (U i : text) {
    ans += (i == character);
  }
  return ans;
}
long long power(long long base, long long exponent, long long module) {
  if (exponent % 2) {
    return power(base, exponent - 1, module) * base % module;
  } else if (exponent) {
    long long root_ans = power(base, exponent / 2, module);
    return root_ans * root_ans % module;
  } else {
    return 1;
  }
}
struct position {
  int y, x;
};
position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template <class T, class U>
string to_string(pair<T, U> x) {
  return to_string(x.first) + "," + to_string(x.second);
}
template <class itr>
void array_output(itr start, itr goal) {
  string ans;
  for (auto i = start; i != goal; i++) {
    ans += to_string(*i) + " ";
  }
  ans.pop_back();
  cout << ans << endl;
}
template <class itr>
void cins(itr start, itr goal) {
  for (auto i = start; i != goal; i++) {
    cin >> (*i);
  }
}
template <class T>
T gcd(T a, T b) {
  if (a && b) {
    return gcd(min(a, b), max(a, b) % min(a, b));
  } else {
    return a;
  }
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
struct combination {
  vector<long long> fact, inv;
  combination(int sz) : fact(sz + 1), inv(sz + 1) {
    fact[0] = 1;
    for (int i = 1; i <= sz; i++) {
      fact[i] = fact[i - 1] * i % (long long)(1e9 + 7);
    }
    inv[sz] = power(fact[sz], (long long)(1e9 + 7) - 2, (long long)(1e9 + 7));
    for (int i = sz - 1; i >= 0; i--) {
      inv[i] = inv[i + 1] * (i + 1) % (long long)(1e9 + 7);
    }
  }
  long long C(int p, int q) const {
    if (q < 0 || p < q) return 0;
    return (fact[p] * inv[q] % (long long)(1e9 + 7) * inv[p - q] %
            (long long)(1e9 + 7));
  }
};
int main() {
  int N;
  long long x;
  cin >> N >> x;
  long long a[N];
  cins(a, a + N);
  long long cost[N];
  for (int i = 0; i < N; i++) {
    cost[i] = a[i];
  }
  long long ans = accumulate(cost, cost + N, 0l);
  for (int i = 1; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cost[j] = min(cost[j], cost[(j - i + N) % N]);
    }
    ans = min(ans, accumulate(cost, cost + N, 0l) + i * x);
  }
  cout << ans << endl;
}
