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 llong = long long;
using ullong = unsigned long long;
std::chrono::system_clock::time_point start;
void TimeStart(void) { start = std::chrono::system_clock::now(); }
void TimeEnd(void) {
  auto time = std::chrono::system_clock::now() - start;
  auto msec =
      std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
  cerr << endl << msec << " msec " << endl;
}
struct AX {
  llong create_time_;
  llong change_time_;
  AX() {
    create_time_ = (llong)pow(10, 9);
    change_time_ = (llong)pow(10, 9);
  }
  bool operator<(const AX& ax) const { return change_time_ < ax.change_time_; }
  bool operator>(const AX& ax) const { return change_time_ > ax.change_time_; }
};
class AGC004B {
 public:
  AGC004B() {
    cin >> n_;
    cin >> x_;
    a_.resize(n_);
    for (llong i = 0; i < n_; i++) cin >> a_[i];
    ax_.resize(n_);
  }
  void Run(void) {
    llong ans = 0;
    for (llong i = 0; i < n_; i++) MinAX(i, ax_[i]);
    sort((ax_).begin(), (ax_).end(), greater<AX>());
    for (llong i = 0; i < n_; i++) ans += ax_[i].create_time_;
    ans += ax_[0].change_time_;
    cout << ans;
  }

 private:
  void MinAX(llong index, AX& axmin) {
    AX ax;
    for (llong i = 0; i < n_; i++) {
      if (index == i) {
        ax.create_time_ = a_[i];
        ax.change_time_ = 0;
      } else if (index < i) {
        ax.create_time_ = a_[i];
        ax.change_time_ = x_ * ((llong)a_.size() - (i - index));
      } else {
        ax.create_time_ = a_[i];
        ax.change_time_ = x_ * (index - i);
      }
      if (ax.create_time_ + ax.change_time_ <
          axmin.create_time_ + axmin.change_time_) {
        axmin.create_time_ = ax.create_time_;
        axmin.change_time_ = ax.change_time_;
      }
    }
  }
  llong n_;
  llong x_;
  vector<llong> a_;
  vector<AX> ax_;
};
int main(void) {
  AGC004B agc004b;
  agc004b.Run();
  return 0;
}
