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;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios {
  fast_ios() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  };
} fast_ios_;
template <typename T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &e : v) is >> e;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (auto &e : v) os << e << " ";
  return os;
}
template <typename T>
inline int count_between(vector<T> &a, T l, T r) {
  return lower_bound(a.begin(), a.end(), r) -
         lower_bound(a.begin(), a.end(), l);
}
inline int Log2(ll x) {
  int k;
  for (k = 0; x > 0; ++k) x >>= 1;
  return k;
}
const int INF = 1 << 30;
const ll INFll = 1ll << 62;
const ld EPS = 1e-10;
const int MOD = int(1e9) + 7;
template <typename T>
struct edge {
  int v;
  T w;
  edge(int v, T w) : v(v), w(w) {}
};
template <typename T>
using Edges = vector<edge<T>>;
template <typename T>
using Graph = vector<Edges<T>>;
V cnt;
template <typename T>
vector<T> dijkstra(Graph<T> &G, int s) {
  const auto INF = numeric_limits<T>::max();
  vector<T> dist(G.size(), INF);
  using PTi = pair<T, int>;
  priority_queue<PTi, vector<PTi>, greater<PTi>> pq;
  dist[s] = 0;
  pq.emplace(dist[s], s);
  while (!pq.empty()) {
    T cost;
    int u;
    tie(cost, u) = pq.top();
    pq.pop();
    if (dist[u] < cost) continue;
    for (auto &e : G[u]) {
      auto n_cost = cost + e.w;
      if (dist[e.v] <= n_cost) continue;
      dist[e.v] = n_cost;
      pq.emplace(dist[e.v], e.v);
      if (u != s) cnt[e.v] = cnt[u] + 1;
    }
  }
  return dist;
}
int main() {
  ll n, x;
  cin >> n >> x;
  Vll a(n);
  cin >> a;
  cnt.assign(n, 0);
  Graph<ll> G(n + 1);
  for (int i = int(0); i < int(n); ++i) {
    G[n].emplace_back(i, a[i]);
    G[i].emplace_back((i + 1) % n, x);
  }
  auto dst = dijkstra(G, n);
  ll ans = *max_element(cnt.begin(), cnt.end()) * x;
  for (int i = int(0); i < int(n); ++i) {
    if (cnt[i] == 0) {
      ll y = cnt[(i - 1 + n) % n];
      ans += (y + 1) * a[(i - 1 - y + n) % n];
    }
  }
  cout << ans << endl;
  return 0;
}
