#include <bits/stdc++.h>
using namespace std;
namespace IO {
struct q_instream {
  template <typename classT>
  inline q_instream operator>>(classT &e) const {
    e = 0;
    classT f = 1, c = 0;
    while (c < '0' || c > '9') {
      if (c == '-') f = -1;
      c = getchar();
    }
    while (c >= '0' && c <= '9') e = e * 10 + c - '0', c = getchar();
    return e = e * f, (*this);
  }
} in;
struct q_outstream {
  template <typename classT>
  inline q_outstream operator<<(const classT &e) const {
    if (e < 0) {
      putchar('-');
      (*this) << -e;
    } else {
      if (e > 9) (*this) << (e / 10);
      putchar(e % 10 + '0');
    }
    return (*this);
  }
  inline q_outstream operator<<(const char &c) const {
    return putchar(c), (*this);
  }
} out;
}  // namespace IO
using namespace IO;
long long b[105000];
long long n, a, r, m;
long long sum;
vector<long long> h;
vector<long long> cum(n + 1);
long long get_cost(long long x) {
  auto res = 0LL;
  if (sum < x * n) {
    res += a * (x * n - sum);
    long long j = upper_bound(begin(h), end(h), x) - begin(h);
    res += min(m, a + r) * (cum[j] - (n - j) * x);
  } else {
    res += r * (sum - x * n);
    long long j = lower_bound(begin(h), end(h), x) - begin(h);
    res += min(m, a + r) * (j * x - (cum[0] - cum[j]));
  }
  return res;
};
long long maxe = 100;
long long pos[1000];
long long best_ans = 0x3f3f3f3f3f3f3f3f;
const double BeginT = 10000, EndT = 1e-10, ChangeT = 0.999;
long long y;
typedef std::subtract_with_carry_engine<std::uint_fast64_t, 48, 5, 12>
    ranlux48_base;
ranlux48_base rb;
void SA(long long times) {
  long long x, pre, tmp_ans;
  while (times--) {
    for (double T = BeginT; T > EndT; T *= ChangeT) {
      pre = x;
      x = (b[1] + (long long)((long long)(rb()) * ChangeT)) %
              (b[n] + 1 - b[1]) +
          1;
      x += rb() % 2;
      x -= rb() % 2;
      tmp_ans = get_cost(x);
      if (tmp_ans <= best_ans) {
        best_ans = tmp_ans;
        y = x;
      } else if (exp((best_ans - tmp_ans) / T) > (double)rand() / RAND_MAX) {
        x = pre;
      }
    }
  }
  return;
}
signed main() {
  cin >> n >> a >> r >> m;
  long long o;
  for (long long i = 1; i <= n; i++) cin >> b[i], h.push_back(b[i]);
  sort(b + 1, b + n + 1);
  sort(begin(h), end(h));
  sum = accumulate(begin(h), end(h), 0LL);
  for (long long i = 0; i <= n; i++) cum.push_back(0);
  for (long long i = n; i--;) {
    cum[i] = h[i] + cum[i + 1];
  }
  SA(25);
  for (long long i = 1; i <= n; i++) best_ans = min(best_ans, get_cost(b[i]));
  for (long long i = max(y - 6005000, (long long)1); i <= y + 6005000; i++) {
    best_ans = min(best_ans, get_cost(i));
  }
  cout << best_ans << endl;
  return 0;
}

### Prompt

Generate a Cpp solution to the following problem:

You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restoration all the N pillars should have equal heights.

You are allowed the following operations:

  * put a brick on top of one pillar, the cost of this operation is A;
  * remove a brick from the top of one non-empty pillar, the cost of this operation is R;
  * move a brick from the top of one non-empty pillar to the top of another pillar, the cost of this operation is M.



You cannot create additional pillars or ignore some of pre-existing pillars even if their height becomes 0.

What is the minimal total cost of restoration, in other words, what is the minimal total cost to make all the pillars of equal height?

Input

The first line of input contains four integers N, A, R, M (1 ≤ N ≤ 10^{5}, 0 ≤ A, R, M ≤ 10^{4}) — the number of pillars and the costs of operations.

The second line contains N integers h_{i} (0 ≤ h_{i} ≤ 10^{9}) — initial heights of pillars.

Output

Print one integer — the minimal cost of restoration.

Examples

Input


3 1 100 100
1 3 8


Output


12


Input


3 100 1 100
1 3 8


Output


9


Input


3 100 100 1
1 3 8


Output


4


Input


5 1 2 4
5 5 3 6 5


Output


4


Input


5 1 2 2
5 5 3 6 5


Output


3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
namespace IO {
struct q_instream {
  template <typename classT>
  inline q_instream operator>>(classT &e) const {
    e = 0;
    classT f = 1, c = 0;
    while (c < '0' || c > '9') {
      if (c == '-') f = -1;
      c = getchar();
    }
    while (c >= '0' && c <= '9') e = e * 10 + c - '0', c = getchar();
    return e = e * f, (*this);
  }
} in;
struct q_outstream {
  template <typename classT>
  inline q_outstream operator<<(const classT &e) const {
    if (e < 0) {
      putchar('-');
      (*this) << -e;
    } else {
      if (e > 9) (*this) << (e / 10);
      putchar(e % 10 + '0');
    }
    return (*this);
  }
  inline q_outstream operator<<(const char &c) const {
    return putchar(c), (*this);
  }
} out;
}  // namespace IO
using namespace IO;
long long b[105000];
long long n, a, r, m;
long long sum;
vector<long long> h;
vector<long long> cum(n + 1);
long long get_cost(long long x) {
  auto res = 0LL;
  if (sum < x * n) {
    res += a * (x * n - sum);
    long long j = upper_bound(begin(h), end(h), x) - begin(h);
    res += min(m, a + r) * (cum[j] - (n - j) * x);
  } else {
    res += r * (sum - x * n);
    long long j = lower_bound(begin(h), end(h), x) - begin(h);
    res += min(m, a + r) * (j * x - (cum[0] - cum[j]));
  }
  return res;
};
long long maxe = 100;
long long pos[1000];
long long best_ans = 0x3f3f3f3f3f3f3f3f;
const double BeginT = 10000, EndT = 1e-10, ChangeT = 0.999;
long long y;
typedef std::subtract_with_carry_engine<std::uint_fast64_t, 48, 5, 12>
    ranlux48_base;
ranlux48_base rb;
void SA(long long times) {
  long long x, pre, tmp_ans;
  while (times--) {
    for (double T = BeginT; T > EndT; T *= ChangeT) {
      pre = x;
      x = (b[1] + (long long)((long long)(rb()) * ChangeT)) %
              (b[n] + 1 - b[1]) +
          1;
      x += rb() % 2;
      x -= rb() % 2;
      tmp_ans = get_cost(x);
      if (tmp_ans <= best_ans) {
        best_ans = tmp_ans;
        y = x;
      } else if (exp((best_ans - tmp_ans) / T) > (double)rand() / RAND_MAX) {
        x = pre;
      }
    }
  }
  return;
}
signed main() {
  cin >> n >> a >> r >> m;
  long long o;
  for (long long i = 1; i <= n; i++) cin >> b[i], h.push_back(b[i]);
  sort(b + 1, b + n + 1);
  sort(begin(h), end(h));
  sum = accumulate(begin(h), end(h), 0LL);
  for (long long i = 0; i <= n; i++) cum.push_back(0);
  for (long long i = n; i--;) {
    cum[i] = h[i] + cum[i + 1];
  }
  SA(25);
  for (long long i = 1; i <= n; i++) best_ans = min(best_ans, get_cost(b[i]));
  for (long long i = max(y - 6005000, (long long)1); i <= y + 6005000; i++) {
    best_ans = min(best_ans, get_cost(i));
  }
  cout << best_ans << endl;
  return 0;
}

```