#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T>
inline bool setmin(T &a, T b) {
  if (a > b) return a = b, 1;
  return 0;
}
template <class T>
inline bool setmax(T &a, T b) {
  if (a < b) return a = b, 1;
  return 0;
}
template <class T>
inline T fast(T a, T b, T mod) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
template <class T>
istream &operator>>(istream &os, vector<T> &container) {
  for (auto &u : container) os >> u;
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &container) {
  for (auto &u : container) os << u << " ";
  return os;
}
template <class T>
inline T gcd(T a, T b) {
  while (b) swap(a %= b, b);
  return a;
}
const long long INF = 1e9 + 7;
const long long mod = 998244353;
const long long BIG_INF = 1e18 + 7;
const long long N = 1e6 + 7;
const long long T = 1 << 20;
const long double inf = 1e18;
long long n, m, k, q;
long long a, r;
vector<long long> tab;
long long policz(long long wys) {
  long long suma = 0;
  long long ile_nad = 0;
  long long ile_pod = 0;
  for (auto &u : tab) {
    suma += u;
    ile_nad += max(0LL, u - wys);
    ile_pod += max(0LL, wys - u);
  }
  long long koniec = n * wys;
  long long ans = 0;
  long long pom = abs(koniec - suma);
  if (suma < koniec) {
    ans += a * pom;
    ans += m * (ile_pod - pom);
  } else {
    ans += r * pom;
    ans += m * (ile_nad - pom);
  }
  return ans;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> a >> r >> m;
  m = min(m, a + r);
  tab.resize(n);
  cin >> tab;
  long long L = 0;
  long long R = INF;
  while (R - L > 5) {
    int third = (R - L) / 3;
    int A = L + third;
    int B = R - third;
    long long wyn_A = policz(A);
    long long wyn_B = policz(B);
    if (wyn_A < wyn_B)
      R = B;
    else
      L = A + 1;
  }
  long long ans = BIG_INF;
  for (int i = L; i < R; i++) {
    ans = min(ans, policz(i));
  }
  cout << ans << '\n';
}

### Prompt

Please formulate 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>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T>
inline bool setmin(T &a, T b) {
  if (a > b) return a = b, 1;
  return 0;
}
template <class T>
inline bool setmax(T &a, T b) {
  if (a < b) return a = b, 1;
  return 0;
}
template <class T>
inline T fast(T a, T b, T mod) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
template <class T>
istream &operator>>(istream &os, vector<T> &container) {
  for (auto &u : container) os >> u;
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &container) {
  for (auto &u : container) os << u << " ";
  return os;
}
template <class T>
inline T gcd(T a, T b) {
  while (b) swap(a %= b, b);
  return a;
}
const long long INF = 1e9 + 7;
const long long mod = 998244353;
const long long BIG_INF = 1e18 + 7;
const long long N = 1e6 + 7;
const long long T = 1 << 20;
const long double inf = 1e18;
long long n, m, k, q;
long long a, r;
vector<long long> tab;
long long policz(long long wys) {
  long long suma = 0;
  long long ile_nad = 0;
  long long ile_pod = 0;
  for (auto &u : tab) {
    suma += u;
    ile_nad += max(0LL, u - wys);
    ile_pod += max(0LL, wys - u);
  }
  long long koniec = n * wys;
  long long ans = 0;
  long long pom = abs(koniec - suma);
  if (suma < koniec) {
    ans += a * pom;
    ans += m * (ile_pod - pom);
  } else {
    ans += r * pom;
    ans += m * (ile_nad - pom);
  }
  return ans;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> a >> r >> m;
  m = min(m, a + r);
  tab.resize(n);
  cin >> tab;
  long long L = 0;
  long long R = INF;
  while (R - L > 5) {
    int third = (R - L) / 3;
    int A = L + third;
    int B = R - third;
    long long wyn_A = policz(A);
    long long wyn_B = policz(B);
    if (wyn_A < wyn_B)
      R = B;
    else
      L = A + 1;
  }
  long long ans = BIG_INF;
  for (int i = L; i < R; i++) {
    ans = min(ans, policz(i));
  }
  cout << ans << '\n';
}

```