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;
const long long INF = 1e15;
template <typename X>
struct SegTree {
  using FX = function<X(X, X)>;
  int n;
  FX fx;
  const X ex;
  vector<X> dat;
  SegTree(int n_, FX fx_, X ex_) : n(), fx(fx_), ex(ex_), dat(n_ * 4, ex_) {
    int x = 1;
    while (n_ > x) {
      x *= 2;
    }
    n = x;
  }
  void set(int i, X x) { dat[i + n - 1] = x; }
  void build() {
    for (int k = n - 2; k >= 0; k--)
      dat[k] = fx(dat[2 * k + 1], dat[2 * k + 2]);
  }
  void update(int i, X x) {
    i += n - 1;
    dat[i] = x;
    while (i > 0) {
      i = (i - 1) / 2;
      dat[i] = fx(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
  }
  X get(int i) { return dat[i + n - 1]; }
  X all() { return dat[0]; }
  X query(int a, int b) { return query_sub(a, b, 0, 0, n); }
  X query_sub(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) {
      return ex;
    } else if (a <= l && r <= b) {
      return dat[k];
    } else {
      X vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
      X vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
      return fx(vl, vr);
    }
  }
  int find_rightest(int a, int b, X x) {
    return find_rightest_sub(a, b, x, 0, 0, n);
  }
  int find_leftest(int a, int b, X x) {
    return find_leftest_sub(a, b, x, 0, 0, n);
  }
  int find_rightest_sub(int a, int b, X x, int k, int l, int r) {
    if (dat[k] > x || r <= a || b <= l) {
      return a - 1;
    } else if (k >= n - 1) {
      return (k - (n - 1));
    } else {
      int vr = find_rightest_sub(a, b, x, 2 * k + 2, (l + r) / 2, r);
      if (vr != a - 1) {
        return vr;
      } else {
        return find_rightest_sub(a, b, x, 2 * k + 1, l, (l + r) / 2);
      }
    }
  }
  int find_leftest_sub(int a, int b, X x, int k, int l, int r) {
    if (dat[k] > x || r <= a || b <= l) {
      return b;
    } else if (k >= n - 1) {
      return (k - (n - 1));
    } else {
      int vl = find_leftest_sub(a, b, x, 2 * k + 1, l, (l + r) / 2);
      if (vl != b) {
        return vl;
      } else {
        return find_leftest_sub(a, b, x, 2 * k + 2, (l + r) / 2, r);
      }
    }
  }
};
int main() {
  int n, x;
  cin >> n >> x;
  using X = long long;
  auto fx = [](X x1, X x2) -> X { return min(x1, x2); };
  X ex = INF;
  SegTree<X> seg(n, fx, ex);
  for (int i = 0; i < (int)(n); i++) {
    int y;
    cin >> y;
    seg.set(i, y);
  }
  seg.build();
  long long mi = INF;
  for (int i = 0; i < (int)(n); i++) {
    long long sum = 0;
    for (int j = 0; j < (int)(n); j++) {
      if (j - i >= 0)
        sum += seg.query(j - i, j + 1);
      else {
        int l = n + j - i;
        sum += min(seg.query(0, j + 1), seg.query(l, n - 1));
      }
    }
    mi = min(mi, sum + x * i);
  }
  cout << mi << endl;
  return 0;
}
