#include <bits/stdc++.h>
long long q_pow(long long x, long long n, long long mod) {
  long long ret = 1;
  while (n) {
    if (n & 1) ret = x * ret % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return ret;
}
long long __gcd(long long x, long long y) {
  if (!y) return x;
  return __gcd(y, x % y);
}
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
using namespace std;
const long long INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
long long num[maxn];
long long n, a, r, m;
long long check(long long x) {
  long long up = 0, down = 0;
  for (int i = 1; i <= n; i++)
    if (num[i] > x)
      down += num[i] - x;
    else
      up += x - num[i];
  if (a + r > m) {
    long long tmp = min(up, down);
    return tmp * m + (up - tmp) * a + (down - tmp) * r;
  }
  return a * up + r * down;
}
signed main(int argc, char *argv[]) {
  if (argc == 2 && strcmp("-debug", argv[1]) == 0) {
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  }
  cin >> n >> a >> r >> m;
  for (int i = 1; i <= n; i++) scanf("%lld", &num[i]);
  long long le = 0, ri = 1e9;
  while (le + 1 < ri) {
    long long mid = (le + ri) / 2;
    long long lmid = le + (ri - le) / 3;
    long long rmid = ri - (ri - le) / 3;
    if (check(mid - 1) <= check(mid + 1))
      ri = mid;
    else
      le = mid;
  }
  cout << min(check(ri), check(le)) << endl;
  return 0;
}

### Prompt

Develop a solution in CPP to the problem described below:

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>
long long q_pow(long long x, long long n, long long mod) {
  long long ret = 1;
  while (n) {
    if (n & 1) ret = x * ret % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return ret;
}
long long __gcd(long long x, long long y) {
  if (!y) return x;
  return __gcd(y, x % y);
}
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
using namespace std;
const long long INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
long long num[maxn];
long long n, a, r, m;
long long check(long long x) {
  long long up = 0, down = 0;
  for (int i = 1; i <= n; i++)
    if (num[i] > x)
      down += num[i] - x;
    else
      up += x - num[i];
  if (a + r > m) {
    long long tmp = min(up, down);
    return tmp * m + (up - tmp) * a + (down - tmp) * r;
  }
  return a * up + r * down;
}
signed main(int argc, char *argv[]) {
  if (argc == 2 && strcmp("-debug", argv[1]) == 0) {
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  }
  cin >> n >> a >> r >> m;
  for (int i = 1; i <= n; i++) scanf("%lld", &num[i]);
  long long le = 0, ri = 1e9;
  while (le + 1 < ri) {
    long long mid = (le + ri) / 2;
    long long lmid = le + (ri - le) / 3;
    long long rmid = ri - (ri - le) / 3;
    if (check(mid - 1) <= check(mid + 1))
      ri = mid;
    else
      le = mid;
  }
  cout << min(check(ri), check(le)) << endl;
  return 0;
}

```