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;
struct edge {
  long long to, cost;
};
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void debug(vector<long long> v) {
  for (long long i = 0; i < v.size(); ++i) cout << v[i] << " ";
  cout << endl;
}
const int inf = 1 << 28;
const long long INF = 1LL << 60;
const long long MAX = 200005;
const long long MOD = 1e9 + 7;
long long fac[MAX], finv[MAX], inv[MAX];
struct Graph {
 public:
  long long V;
  vector<vector<edge>> G;
  vector<vector<long long>> Gmat;
  Graph(long long node) {
    V = node;
    G.resize(V);
  }
  void add(long long from, long long to, long long cost = 1) {
    G[from].push_back({to, cost});
  }
  vector<vector<long long>> WarshallFloyd() {
    Gmat.resize(V);
    for (long long i = 0; i < V; ++i) {
      Gmat[i].resize(V, INF);
      for (const auto &e : G[i]) {
        Gmat[i][e.to] = e.cost;
      }
    }
    vector<vector<long long>> dist = Gmat;
    for (long long i = 0; i < V; ++i) dist[i][i] = 0;
    for (long long k = 0; k < V; ++k)
      for (long long i = 0; i < V; ++i)
        for (long long j = 0; j < V; ++j)
          chmin(dist[i][j], dist[i][k] + dist[k][j]);
    return dist;
  }
  vector<long long> dijkstra(long long start) {
    vector<long long> dist(V, INF);
    priority_queue<pair<long long, long long>,
                   vector<pair<long long, long long>>,
                   greater<pair<long long, long long>>>
        que;
    dist[start] = 0;
    que.push(pair<long long, long long>(0, start));
    while (!que.empty()) {
      pair<long long, long long> p = que.top();
      que.pop();
      long long v = p.second;
      if (dist[v] < p.first) continue;
      for (long long i = 0; i < G[v].size(); ++i) {
        edge e = G[v][i];
        if (dist[v] + e.cost < dist[e.to]) {
          dist[e.to] = dist[v] + e.cost;
          que.push(pair<long long, long long>(dist[e.to], e.to));
        }
      }
    }
    return dist;
  }
};
class UnionFind {
 public:
  vector<long long> par;
  vector<long long> siz;
  UnionFind(long long sz_) : par(sz_), siz(sz_, 1LL) {
    for (long long i = 0; i < sz_; ++i) par[i] = i;
  }
  void init(long long sz_) {
    par.resize(sz_);
    siz.assign(sz_, 1LL);
    for (long long i = 0; i < sz_; ++i) par[i] = i;
  }
  long long root(long long x) {
    while (par[x] != x) {
      x = par[x] = par[par[x]];
    }
    return x;
  }
  bool merge(long long x, long long y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (siz[x] < siz[y]) swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }
  bool issame(long long x, long long y) { return root(x) == root(y); }
  long long size(long long x) { return siz[root(x)]; }
};
struct SegmentTree {
 private:
  long long unit = INF;
  long long op(long long a, long long b) { return min(a, b); }
  long long n;
  vector<long long> node;

 public:
  SegmentTree(vector<long long> v) {
    long long sz = (long long)v.size();
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n - 1, unit);
    for (long long i = 0; i < sz; i++) node[i + n - 1] = v[i];
    for (long long i = n - 2; i >= 0; i--)
      node[i] = op(node[2 * i + 1], node[2 * i + 2]);
  }
  void update(long long x, long long val) {
    x += n - 1;
    node[x] += val;
    while (x > 0) {
      x = (x - 1) / 2;
      node[x] = op(node[2 * x + 1], node[2 * x + 2]);
    }
  }
  long long query(long long a, long long b, long long k = 0, long long l = 0,
                  long long r = -1) {
    if (r < 0) r = n;
    if (r <= a || b <= l) return unit;
    if (a <= l && r <= b) return node[k];
    long long vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    long long vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return op(vl, vr);
  }
};
struct LazySegmentTree {
 private:
  long long n;
  vector<long long> node, lazy;

 public:
  LazySegmentTree(vector<long long> v) {
    long long sz = (long long)v.size();
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n - 1);
    lazy.resize(2 * n - 1);
    for (long long i = 0; i < sz; i++) node[i + n - 1] = v[i];
    for (long long i = n - 2; i >= 0; i--)
      node[i] = node[2 * i + 1] + node[2 * i + 2];
  }
  void lazyEval(long long k, long long l, long long r) {
    if (lazy[k] != 0) {
      node[k] += lazy[k];
      if (r - l > 1) {
        lazy[2 * k + 1] += lazy[k] / 2;
        lazy[2 * k + 2] += lazy[k] / 2;
      }
      lazy[k] = 0;
    }
  }
  void update(long long a, long long b, long long x, long long k = 0,
              long long l = 0, long long r = -1) {
    if (r < 0) r = n;
    lazyEval(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] += (r - l) * x;
      lazyEval(k, l, r);
    } else {
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      node[k] = node[2 * k + 1] + node[2 * k + 2];
    }
  }
  long long query(long long a, long long b, long long k = 0, long long l = 0,
                  long long r = -1) {
    if (r < 0) r = n;
    if (b <= l || r <= a) return 0;
    lazyEval(k, l, r);
    if (a <= l && r <= b) return node[k];
    long long vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    long long vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return vl + vr;
  }
  long long at(long long a) { return query(a, a + 1); }
};
long long modpow(long long a, long long n, long long mod = MOD) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (long long i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(long long n, long long k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
void division(map<long long, long long> &hash, long long num) {
  while (1 < num) {
    bool flag = true;
    long long t = (long long)pow(num, 1 / 2.0) + 1;
    for (long long i = 2; i < t; ++i) {
      if (num % i == 0) {
        flag = false;
        if (!hash.count(i)) {
          hash[i] = 1;
        } else {
          hash[i] += 1;
        }
        num /= i;
        break;
      }
    }
    if (flag) {
      if (!hash.count(num)) {
        hash[num] = 1;
      } else {
        hash[num] += 1;
      }
      return;
    }
  }
  return;
}
int main() {
  long long N, x;
  cin >> N >> x;
  vector<long long> a(N);
  for (long long i = 0; i < N; ++i) cin >> a[i];
  SegmentTree t(a);
  long long ans = INF;
  for (long long i = 0; i < N; ++i) {
    long long res = x * i;
    if (i == 0) {
      for (long long j = 0; j < N; ++j) {
        res += a[j];
      }
    } else {
      for (long long j = 0; j < N; ++j) {
        if (0 <= j - (i + 1)) {
          res += t.query((j) - (i + 1), (j) + 1);
        } else {
          res += min(t.query(0, j + 1), t.query(N - (i - j), N));
        }
      }
    }
    cout << res << endl;
    chmin(ans, res);
  }
  return 0;
}
