/*
 * Author:  heyuhhh
 * Created Time:  2020/5/16 20:43:52
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A>
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

ll n, a, r, m;
ll h[N];
ll sum[N];
ll ans = 1e18;

ll calc(int l, int r) {
    return sum[r] - sum[l - 1];
}

bool chk(ll x, ll i) {
    ll now = calc(i, n) - (n - i + 1) * x;
    ll r = x * (i - 1) - calc(1, i - 1);
    return now <= r;
}

void solve1() {
    ll H = h[n];
    for (int i = n; i >= 1; i--) {
        int l = h[i - 1], r = h[i] + 1, mid;
        while (l < r) {
            mid = (l + r) >> 1;
            if (chk(mid, i)) r = mid;
            else l = mid + 1;
        }
        if (l > h[i]) break;
        H = l;
    }
    ll res = 1e18;

    int p = lower_bound(h + 1, h + n + 1, H) - h;
    ll now = calc(p, n) - (n - p + 1) * H;
    ll R = (p - 1) * H - calc(1, p - 1);
    res = m * now + (R - now) * a;

    --H;
    p = lower_bound(h + 1, h + n + 1, H) - h;
    now = calc(p, n) - (n - p + 1) * H;
    R = (p - 1) * H - calc(1, p - 1);
    res = min(res, m * now + (now - R) * r);

    res = min(res, ((n - 1) * h[n] - calc(1, n - 1)) * a);
    res = min(res, (calc(2, n) - (n - 1) * h[1]) * r);
    ans = min(ans, res);
}

void solve2() {
    for (int i = n; i >= 1; i--) {
        ll res = r * (calc(i + 1, n) - (n - i) * h[i]) + ((i - 1) * h[i] - calc(1, i - 1)) * a;
        ans = min(ans, res);
    }
}

void run() {
    cin >> n >> a >> r >> m;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    sort(h + 1, h + n + 1);
    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + h[i];
    }
    solve1();
    solve2();
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}


/*
 * Author:  heyuhhh
 * Created Time:  2020/5/16 20:43:52
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A>
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

ll n, a, r, m;
ll h[N];
ll sum[N];
ll ans = 1e18;

ll calc(int l, int r) {
    return sum[r] - sum[l - 1];
}

bool chk(int x, int i) {
    ll now = calc(i, n) - (n - i + 1) * x;
    ll r = x * (i - 1) - calc(1, i - 1);
    return now <= r;
}

void solve1() {
    ll H = h[n];
    for (int i = n; i >= 1; i--) {
        int l = h[i - 1], r = h[i] + 1, mid;
        while (l < r) {
            mid = (l + r) >> 1;
            if (chk(mid, i)) r = mid;
            else l = mid + 1;
        }
        if (l > h[i]) break;
        H = l;
    }
    ll res = 1e18;

    int p = lower_bound(h + 1, h + n + 1, H) - h;
    ll now = calc(p, n) - (n - p + 1) * H;
    ll R = (p - 1) * H - calc(1, p - 1);
    if (now <= R) {
        res = 1ll * m * now + (R - now) * a;
    }

    --H;
    p = lower_bound(h + 1, h + n + 1, H) - h;
    now = calc(p, n) - (n - p + 1) * H;
    R = (p - 1) * H - calc(1, p - 1);
    if (now >= R) {
        res = min(res, m * now + (now - R) * r);
    }

    res = min(res, ((n - 1) * h[n] - calc(1, n - 1)) * a);
    res = min(res, (calc(2, n) - (n - 1) * h[1]) * r);
    ans = min(ans, res);
}

void solve2() {
    for (int i = n; i >= 1; i--) {
        ll res = r * (calc(i + 1, n) - (n - i) * h[i]) + ((i - 1) * h[i] - calc(1, i - 1)) * a;
        ans = min(ans, res);
    }
}

void run() {
    cin >> n >> a >> r >> m;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    sort(h + 1, h + n + 1);
    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + h[i];
    }
    solve1();
    solve2();
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}


/*
 * Author:  heyuhhh
 * Created Time:  2020/5/16 20:43:52
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A>
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

ll n, a, r, m;
ll h[N];
ll sum[N];
ll ans = 1e18;

ll calc(int l, int r) {
    return sum[r] - sum[l - 1];
}

bool chk(ll x, ll i) {
    ll now = calc(i, n) - (n - i + 1) * x;
    ll r = x * (i - 1) - calc(1, i - 1);
    return now <= r;
}

void solve1() {
    ll H = h[n];
    for (int i = n; i >= 1; i--) {
        int l = h[i - 1], r = h[i] + 1, mid;
        while (l < r) {
            mid = (l + r) >> 1;
            if (chk(mid, i)) r = mid;
            else l = mid + 1;
        }
        if (l > h[i]) break;
        H = l;
    }
    ll res = 1e18;

    int p = lower_bound(h + 1, h + n + 1, H) - h;
    ll now = calc(p, n) - (n - p + 1) * H;
    ll R = (p - 1) * H - calc(1, p - 1);
    res = m * now + (R - now) * a;

    --H;
    p = lower_bound(h + 1, h + n + 1, H) - h;
    now = calc(p, n) - (n - p + 1) * H;
    R = (p - 1) * H - calc(1, p - 1);
    res = min(res, m * now + (now - R) * r);
    ans = min(ans, res);
}

void solve2() {
    for (int i = n; i >= 1; i--) {
        ll res = r * (calc(i + 1, n) - (n - i) * h[i]) + ((i - 1) * h[i] - calc(1, i - 1)) * a;
        ans = min(ans, res);
    }
}

void run() {
    cin >> n >> a >> r >> m;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    sort(h + 1, h + n + 1);
    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + h[i];
    }
    solve1();
    solve2();
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}


/*
 * Author:  heyuhhh
 * Created Time:  2020/5/16 20:43:52
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A>
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

int n, a, r, m;
int h[N];
ll sum[N];

ll calc(int l, int r) {
    return sum[r] - sum[l - 1];
}

bool chk(int x, int i) {
    ll now = calc(i, n) - 1ll * (n - i + 1) * x;
    ll r = 1ll * x * (i - 1) - calc(1, i - 1);
    return now <= r;
}

void solve1() {
    ll ans = 1e18;
    for (int i = n; i >= 2; i--) {
        int l = h[i - 1], r = h[i] + 1, mid;
        while (l < r) {
            mid = (l + r) >> 1;
            if (chk(mid, i)) r = mid;
            else l = mid + 1;
        }
        if (l > h[i]) break;
        ll now = calc(i, n) - 1ll * (n - i + 1) * l;
        ll res = 1ll * m * now + (1ll * (i - 1) * l - calc(1, i - 1) - now) * a;
        ans = min(ans, res);
    }
    ll res = (1ll * (n - 1) * h[n] - calc(1, n - 1)) * a;
    ans = min(ans, res);
    res = (calc(2, n) - 1ll * (n - 1) * h[1]) * r;
    ans = min(ans, res);
    cout << ans << '\n';
}

void solve2() {
    ll ans = 1e18;
    for (int i = n; i >= 1; i--) {
        ll res = 1ll * r * (calc(i + 1, n) - 1ll * (n - i) * h[i]) + (1ll * (i - 1) * h[i] - calc(1, i - 1)) * a;
        ans = min(ans, res);
    }
    cout << ans << '\n';
}

void run() {
    cin >> n >> a >> r >> m;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    sort(h + 1, h + n + 1);
    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + h[i];
    }
    if (m < a + r) {
        solve1();
    } else {
        solve2();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}


/*
 * Author:  heyuhhh
 * Created Time:  2020/5/16 20:43:52
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A>
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

int n, a, r, m;
int h[N];
ll sum[N];

ll calc(int l, int r) {
    return sum[r] - sum[l - 1];
}

bool chk(int x, int i) {
    ll now = calc(i, n) - 1ll * (n - i + 1) * x;
    ll r = 1ll * x * (i - 1) - calc(1, i - 1);
    return now <= r;
}

void solve1() {
    ll ans = 1e18;
    ll H;
    for (int i = n; i >= 2; i--) {
        int l = h[i - 1], r = h[i] + 1, mid;
        while (l < r) {
            mid = (l + r) >> 1;
            if (chk(mid, i)) r = mid;
            else l = mid + 1;
        }
        if (l > h[i]) break;
        H = l;
        ll now = calc(i, n) - 1ll * (n - i + 1) * l;
        ll res = 1ll * m * now + (1ll * (i - 1) * l - calc(1, i - 1) - now) * a;
        ans = min(ans, res);
    }
    --H;
    int p = lower_bound(h + 1, h + n + 1, H) - h;
    ll now = calc(p, n) - 1ll * (n - p + 1) * H;
    ll R = 1ll * (p - 1) * H - calc(1, p - 1);
    ll res = 1e18;
    if (now >= R) {
        res = 1ll * m * now + 1ll * (now - R) * r;
    }
    ans = min(ans, res);
    res = (1ll * (n - 1) * h[n] - calc(1, n - 1)) * a;
    ans = min(ans, res);
    res = (calc(2, n) - 1ll * (n - 1) * h[1]) * r;
    ans = min(ans, res);
    cout << ans << '\n';
}

void solve2() {
    ll ans = 1e18;
    for (int i = n; i >= 1; i--) {
        ll res = 1ll * r * (calc(i + 1, n) - 1ll * (n - i) * h[i]) + (1ll * (i - 1) * h[i] - calc(1, i - 1)) * a;
        ans = min(ans, res);
    }
    cout << ans << '\n';
}

void run() {
    cin >> n >> a >> r >> m;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    sort(h + 1, h + n + 1);
    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + h[i];
    }
    if (m < a + r) {
        solve1();
    } else {
        solve2();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}


/*
 * Author:  heyuhhh
 * Created Time:  2020/5/16 20:43:52
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
//#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A>
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

ll n, a, r, m;
ll h[N];
ll sum[N];
ll ans = 1e18;

ll calc(int l, int r) {
    return sum[r] - sum[l - 1];
}

bool chk(ll x, ll i) {
    ll now = calc(i, n) - (n - i + 1) * x;
    ll r = x * (i - 1) - calc(1, i - 1);
    return now <= r;
}

void solve1() {
    ll H = h[n];
    for (int i = n; i >= 1; i--) {
        int l = h[i - 1], r = h[i] + 1, mid;
        while (l < r) {
            mid = (l + r) >> 1;
            if (chk(mid, i)) r = mid;
            else l = mid + 1;
        }
        if (l > h[i]) break;
        H = l;
    }
    ll res = 1e18;

    int p = lower_bound(h + 1, h + n + 1, H) - h;
    ll now = calc(p, n) - (n - p + 1) * H;
    ll R = (p - 1) * H - calc(1, p - 1);
    res = m * now + (R - now) * a;

    --H;
    p = lower_bound(h + 1, h + n + 1, H) - h;
    now = calc(p, n) - (n - p + 1) * H;
    R = (p - 1) * H - calc(1, p - 1);
    res = min(res, m * now + (now - R) * r);
    ans = min(ans, res);
}

void solve2() {
    for (int i = n; i >= 1; i--) {
        ll res = r * (calc(i + 1, n) - (n - i) * h[i]) + ((i - 1) * h[i] - calc(1, i - 1)) * a;
        ans = min(ans, res);
    }
}

void run() {
    cin >> n >> a >> r >> m;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    sort(h + 1, h + n + 1);
    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + h[i];
    }
    solve1();
    solve2();
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define pi 3.14159265358979323846

const int N = 110000;
vector<int>arr;
vector<int>pre(N);
int a,r,m;

int calculate(int H){
	int n = arr.size();
	int res = 0;
	int pos = lower_bound(arr.begin(),arr.end(),H) - arr.begin();
	cout << pos << " " << H << endl;
	int P = pre[pos];
	P = H*pos-pre[pos];
	int Q = pre[n]-pre[pos]-H*(n-pos);
	res = min(P,Q);
	P -= res;
	Q -= res;
	res *= m;
	res += P*a;
	res += Q*r;
	return res;
}

int main(){
	int t;
	// cin >> t;
	t = 1;
	while(t--){
		int n;
		cin >> n >> a >> r >> m;
		m = min(m,a+r);
		int num;
		for (int i = 0; i < n; i++)
		{
			cin >> num;
			arr.push_back(num);
		}
		sort(arr.begin(),arr.end());
		for (int i = 0; i < n; i++)
		{
			pre[i+1] = pre[i]+arr[i];
		}
		int ans = INT_MAX;
		ans = min(ans,calculate(floor(pre[n]/n)));
		ans = min(ans,calculate(ceil(pre[n]/n)));
		for (int i = 0; i < n; i++)
		{
			ans = min(ans,calculate(arr[i]));
		}
		cout << ans << endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pi 3.14159265358979323846

const ll N = 1100000;
vector<ll> arr;
long long int pre[N];
ll n,a,r,m;
ll ans = 1e18+7;

ll min(ll a,ll b){
	if (a > b)
	{
		return b;
	}
	return a;
}

ll calculate(ll H){
	ll res = 0;
	ll pos = lower_bound(arr.begin(),arr.end(),H) - arr.begin();
	ll P = pre[pos];
	P = H*pos-pre[pos];
	ll Q = pre[n]-pre[pos]-H*(n-pos);
	res = min(P,Q);
	P -= res;
	Q -= res;
	res *= m;
	res += P*a;
	res += Q*r;
	return res;
}

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);

	ll t;
	// cin >> t;
	t = 1;
	while(t--){
		cin >> n >> a >> r >> m;
		m = min(m,a+r);
		ll num;
		for (ll i = 0; i < n; i++)
		{
			cin >> num;
			arr.push_back(num);
		}
		sort(arr.begin(),arr.end());
		for (ll i = 0; i < n; i++)
		{
			pre[i+1] = pre[i]+arr[i];
			// cout << pre[i+1] << endl;
		}
		ans = min(ans,calculate(floor(pre[n]/n)));
		ans = min(ans,calculate(ceil(pre[n]/n)));
		for (ll i = 0; i < n; i++)
		{
			ans = min(ans,calculate(arr[i]));
		}
		cout << ans << endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define pi 3.14159265358979323846

const int N = 110000;
vector<int>arr;
vector<int>pre(N);
int a,r,m;

int calculate(int H){
	int n = arr.size();
	int res = 0;
	int pos = lower_bound(arr.begin(),arr.end(),H) - arr.begin();
	// cout << pos << " " << H << endl;
	int P = pre[pos];
	P = H*pos-pre[pos];
	int Q = pre[n]-pre[pos]-H*(n-pos);
	res = min(P,Q);
	P -= res;
	Q -= res;
	res *= m;
	res += P*a;
	res += Q*r;
	return res;
}

int main(){
	int t;
	// cin >> t;
	t = 1;
	while(t--){
		int n;
		cin >> n >> a >> r >> m;
		m = min(m,a+r);
		int num;
		for (int i = 0; i < n; i++)
		{
			cin >> num;
			arr.push_back(num);
		}
		sort(arr.begin(),arr.end());
		for (int i = 0; i < n; i++)
		{
			pre[i+1] = pre[i]+arr[i];
		}
		int ans = INT_MAX;
		ans = min(ans,calculate(floor(pre[n]/n)));
		ans = min(ans,calculate(ceil(pre[n]/n)));
		for (int i = 0; i < n; i++)
		{
			ans = min(ans,calculate(arr[i]));
		}
		cout << ans << endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define pi 3.14159265358979323846

const ll N = 110000;
vector<int>arr;
vector<int>pre(N);
ll a,r,m;

ll min(ll a,ll b){
	if (a > b)
	{
		return b;
	}
	return a;
}

ll calculate(ll H){
	ll n = arr.size();
	ll res = 0;
	ll pos = lower_bound(arr.begin(),arr.end(),H) - arr.begin();
	// cout << pos << " " << H << endl;
	ll P = pre[pos];
	P = H*pos-pre[pos];
	ll Q = pre[n]-pre[pos]-H*(n-pos);
	res = min(P,Q);
	P -= res;
	Q -= res;
	res *= m;
	res += P*a;
	res += Q*r;
	return res;
}

int main(){
	ll t;
	// cin >> t;
	t = 1;
	while(t--){
		ll n;
		cin >> n >> a >> r >> m;
		m = min(m,a+r);
		ll num;
		for (ll i = 0; i < n; i++)
		{
			cin >> num;
			arr.push_back(num);
		}
		sort(arr.begin(),arr.end());
		for (ll i = 0; i < n; i++)
		{
			pre[i+1] = pre[i]+arr[i];
		}
		ll ans = INT_MAX;
		ans = min(ans,calculate(floor(pre[n]/n)));
		ans = min(ans,calculate(ceil(pre[n]/n)));
		for (ll i = 0; i < n; i++)
		{
			ans = min(ans,calculate(arr[i]));
		}
		cout << ans << endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pi 3.14159265358979323846

const ll N = 2000000;
vector<ll> arr;
ll pre[N];
ll n,a,r,m;
ll ans = 1e18+7;

ll calculate(ll H){
	ll res = 0;
	ll pos = lower_bound(arr.begin(),arr.end(),H) - arr.begin();
	ll P = pre[pos];
	P = H*pos-pre[pos];
	ll Q = pre[n]-pre[pos]-H*(n-pos);
	res = min(P,Q);
	P -= res;
	Q -= res;
	res *= m;
	res += P*a;
	res += Q*r;
	return res;
}

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);

	ll t;
	// cin >> t;
	t = 1;
	while(t--){
		cin >> n >> a >> r >> m;
		m = min(m,a+r);
		ll num;
		for (ll i = 0; i < n; i++)
		{
			cin >> num;
			arr.push_back(num);
		}
		sort(arr.begin(),arr.end());
		for (ll i = 0; i < n; i++)
		{
			pre[i+1] = pre[i]+arr[i];
		}
		ans = min(ans,calculate((pre[n]/n)));
		ans = min(ans,calculate((pre[n]/n+1)));
		for (ll i = 0; i < n; i++)
		{
			ans = min(ans,calculate(arr[i]));
		}
		cout << ans << endl;
	}
	return 0;
}


/***********It's not at all important to get it right the first time!
            It's vitally important to get it right the last time!!!  ***********/
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define DEBUG(x) cout <<">>"<<#x<<"::"<<(x)<< endl;
#define DEBUG2(x,y) cout<<#x<<"::"<<x<<"    "<<#y<<"::"<<y<<endl;
#define DEBUG3(x,y,z) cout<<#x<<"::"<<x<<"   "<<#y<<"::"<<y<<"   "<<#z<<"::"<<z<<endl;
#define boost ios::sync_with_stdio(0); cin.tie(0)
#define mem(x,val) memset((x),(val),sizeof(x))
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
const ll INF = 2e18;
const ll mod = 1e9+7;
/**************************************************************************/

int main()
{
    boost;
    ll n , A,  R , M;
    cin>>n>>A>>R>>M;
    ll arr[n];
    for(int i =0; i<n; i++) cin>>arr[i];

    ll res = INF;
    ll l=*min_element(arr , arr+n), r = *max_element(arr, arr+n);
    // DEBUG2(l, r);
    while( l<= r ){
        ll mid = (l+r)/2;
        ll x=0, y=0;
        for(int i =0; i<n; i++){
            x += max(0LL ,mid-arr[i]);
            y += max(0LL, arr[i]-mid);
        }
        // DEBUG3(mid, x , y);
        ll z = min(x , y);
        ll tmp = z*((A+R)>M?M:(A+R));
        tmp += (x-z)*A + (y-z)*R;
        res = min(tmp , res);
        if(x > y){
            if( A > R  ){
                r=mid-1;
            }
            else l=mid+1;
        }
        else{
            if(A > R){
                r = mid-1;
            }
            else l = mid+1;;
        }
    }
    cout<<res<<endl;

    return 0;
}


/***********It's not at all important to get it right the first time!
            It's vitally important to get it right the last time!!!  ***********/
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define DEBUG(x) cout <<">>"<<#x<<"::"<<(x)<< endl;
#define DEBUG2(x,y) cout<<#x<<"::"<<x<<"    "<<#y<<"::"<<y<<endl;
#define DEBUG3(x,y,z) cout<<#x<<"::"<<x<<"   "<<#y<<"::"<<y<<"   "<<#z<<"::"<<z<<endl;
#define boost ios::sync_with_stdio(0); cin.tie(0)
#define mem(x,val) memset((x),(val),sizeof(x))
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
const ll INF = 2e18;
const ll mod = 1e9+7;
/**************************************************************************/

ll h[100005];
ll pre[100005];
int n;
ll a , r, m;

ll solve(ll x){
    // DEBUG(x);
    int pos = lower_bound(h , h+n , x) - h;
    ll p1 =  x*pos- pre[pos];
    ll p2 = pre[n] - pre[pos] - (n-pos)*x;
    ll t = min(p1, p2);
    ll res = t*m;
    p1-=t;
    p2-=t;
    res += p1*a + p2*r;
    return res;
}

int main()
{
    boost;
    cin>>n>>a>>r>>m;
    for(int i=0; i<n; i++)
        cin>>h[i];
    sort(h ,h+n);
    for(int i =0; i<n; i++)
        pre[i+1] = pre[i]+h[i];
    ll ans=INF;
    m = min( m , a+r );
    ans = min(ans , solve(pre[n]/n));
    ans = min(ans , solve(pre[n]/n+1));
    for(int i =0; i<n; i++){
        ans = min(ans,  solve(h[i]));
    }
    cout<<ans<<endl;
    return 0;
}


/***********It's not at all important to get it right the first time!
            It's vitally important to get it right the last time!!!  ***********/
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define DEBUG(x) cout <<">>"<<#x<<"::"<<(x)<< endl;
#define DEBUG2(x,y) cout<<#x<<"::"<<x<<"    "<<#y<<"::"<<y<<endl;
#define DEBUG3(x,y,z) cout<<#x<<"::"<<x<<"   "<<#y<<"::"<<y<<"   "<<#z<<"::"<<z<<endl;
#define boost ios::sync_with_stdio(0); cin.tie(0)
#define mem(x,val) memset((x),(val),sizeof(x))
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
const ll INF = 2e18;
const ll mod = 1e9+7;
/**************************************************************************/

ll h[100005];
ll pre[100005];
int n;
ll a , r, m;

ll solve(ll x){
    int pos = lower_bound(h , h+n , x) - h;
    ll p1 =  x*pos- pre[pos];
    ll p2 = pre[n] - pre[pos] - (n-pos)*x;
    ll res = m*min(p1, p2);
    p1-=min(p1, p2);
    p2-=min(p1, p2);
    res += p1*a + p2*r;
    return res;
}

int main()
{
    boost;
    cin>>n>>a>>r>>m;
    for(int i=0; i<n; i++)
        cin>>h[i];
    sort(h ,h+n);
    for(int i =0; i<n; i++)
        pre[i+1] = pre[i]+h[i];
    ll ans=INF;
    m = min( m , a+r );
    ans = min(ans , solve(pre[n-1]/n));
    ans = min(ans , solve(pre[n-1]/n+1));
    for(int i =0; i<n; i++){
        ans = min(ans,  solve(h[i]));
    }
    cout<<ans<<endl;
    return 0;
}


/***********It's not at all important to get it right the first time!
            It's vitally important to get it right the last time!!!  ***********/
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define DEBUG(x) cout <<">>"<<#x<<"::"<<(x)<< endl;
#define DEBUG2(x,y) cout<<#x<<"::"<<x<<"    "<<#y<<"::"<<y<<endl;
#define DEBUG3(x,y,z) cout<<#x<<"::"<<x<<"   "<<#y<<"::"<<y<<"   "<<#z<<"::"<<z<<endl;
#define boost ios::sync_with_stdio(0); cin.tie(0)
#define mem(x,val) memset((x),(val),sizeof(x))
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
const ll INF = 2e18;
const ll mod = 1e9+7;
/**************************************************************************/

ll h[100005];
ll pre[100005];
int n;
ll a , r, m;

ll solve(ll x){
    int pos = lower_bound(h , h+n , x) - h;
    ll p1 =  x*pos- pre[pos];
    ll p2 = pre[n] - pre[pos] - (n-pos)*x;
    ll res = m*min(p1, p2);
    p1-=min(p1, p2);
    p2-=min(p1, p2);
    res += p1*a + p2*r;
    return res;
}

int main()
{
    boost;
    cin>>n>>a>>r>>m;
    for(int i=0; i<n; i++)
        cin>>h[i];
    sort(h ,h+n);
    for(int i =0; i<n; i++)
        pre[i+1] = pre[i]+h[i];
    ll ans=INF;
    m = min( m , a+r );
    ans = min(ans , solve(pre[n]/n));
    ans = min(ans , solve(pre[n]/n+1));
    for(int i =0; i<n; i++){
        ans = min(ans,  solve(h[i]));
    }
    cout<<ans<<endl;
    return 0;
}


/***********It's not at all important to get it right the first time!
            It's vitally important to get it right the last time!!!  ***********/
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define DEBUG(x) cout <<">>"<<#x<<"::"<<(x)<< endl;
#define DEBUG2(x,y) cout<<#x<<"::"<<x<<"    "<<#y<<"::"<<y<<endl;
#define DEBUG3(x,y,z) cout<<#x<<"::"<<x<<"   "<<#y<<"::"<<y<<"   "<<#z<<"::"<<z<<endl;
#define boost ios::sync_with_stdio(0); cin.tie(0)
#define mem(x,val) memset((x),(val),sizeof(x))
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
const ll INF = 2e18;
const ll mod = 1e9+7;
/**************************************************************************/

ll h[100005];
ll pre[100005];
int n;
ll a , r, m;

ll solve(ll x){
    // DEBUG(x);
    int pos = lower_bound(h , h+n , x) - h;
    ll p1 =  x*pos- pre[pos];
    ll p2 = pre[n] - pre[pos] - (n-pos)*x;
    ll t = min(p1, p2);
    ll res = t*m;
    p1-=t;
    p2-=t;
    res += p1*a + p2*r;
    return res;
}

int main()
{
    boost;
    cin>>n>>a>>r>>m;
    for(int i=0; i<n; i++)
        cin>>h[i];
    sort(h ,h+n);
    for(int i =0; i<n; i++)
        pre[i+1] = pre[i]+h[i];
    ll ans=INF;
    m = min( m , a+r );
    ans = min(ans , solve(pre[n]/n));
    ans = min(ans , solve(pre[n]/(n+1)));
    for(int i =0; i<n; i++){
        ans = min(ans,  solve(h[i]));
    }
    cout<<ans<<endl;
    return 0;
}


/***********It's not at all important to get it right the first time!
            It's vitally important to get it right the last time!!!  ***********/
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define DEBUG(x) cout <<">>"<<#x<<"::"<<(x)<< endl;
#define DEBUG2(x,y) cout<<#x<<"::"<<x<<"    "<<#y<<"::"<<y<<endl;
#define DEBUG3(x,y,z) cout<<#x<<"::"<<x<<"   "<<#y<<"::"<<y<<"   "<<#z<<"::"<<z<<endl;
#define boost ios::sync_with_stdio(0); cin.tie(0)
#define mem(x,val) memset((x),(val),sizeof(x))
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
const ll INF = 2e18;
const ll mod = 1e9+7;
/**************************************************************************/

int main()
{
    boost;
    ll n , A,  R , M;
    cin>>n>>A>>R>>M;
    ll arr[n];
    for(int i =0; i<n; i++) cin>>arr[i];

    ll res = INF;
    ll l=0, r = 1e9+7;
    // DEBUG2(l, r);
    while( l<= r ){
        ll mid = (l+r)/2;
        ll x=0, y=0;
        for(int i =0; i<n; i++){
            x += max(0LL ,mid-arr[i]);
            y += max(0LL, arr[i]-mid);
        }
        // DEBUG3(mid, x , y);
        ll z = min(x , y);
        ll tmp = z*((A+R)>M?M:(A+R));
        tmp += (x-z)*A + (y-z)*R;
        res = min(tmp , res);
        if(x > y){
            if( A > R  ){
                r=mid-1;
            }
            else l=mid+1;
        }
        else{
            if(A > R){
                r = mid-1;
            }
            else l = mid+1;;
        }
    }
    cout<<res<<endl;

    return 0;
}


//生存的原因引起了生存的原因
#include <bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,a,r,m;
	cin>>n>>a>>r>>m;
	m=min(m,a+r);
	int total=0;
	int input[n];
	for(int i=0;i<n;i++)
		cin>>input[i];
	sort(input,input+n);
	set<int> st;
	for(int i=0;i<n;i++) st.insert(input[i]);
	for(int i=0;i<n;i++) total+=input[i];
	int suffixSum[n+1],prefixSum[n+1];
	prefixSum[0]=input[0];
	suffixSum[n]=0;
	for(int i=1;i<=n;i++) prefixSum[i]=prefixSum[i-1]+input[i];
	for(int i=n-1;i>=0;i--) suffixSum[i]=suffixSum[i+1]+input[i];
	int  answer=1e17;
	int index=0;
	for(int i=1;i*i<=total;i++)
	{
		if(total%i==0)
		{
			for(int k=0;k<=10;k++)
			{
				st.insert(min(0LL,i-k));
				st.insert(i+k);
				st.insert(min(0LL,total/i-k));
				st.insert(total/i+k);
			}
		}
	}
	for(auto target:st)
	{
		int bricksHere=n*target;
		int cost=0;
		if(bricksHere>total) cost+=a*(bricksHere-total);
		else cost+=r*(total-bricksHere);
		while(index<n && input[index]<target) index++;
		int needLeft=((index)*target-(index?prefixSum[index-1]:0));
		int extraRight=(suffixSum[index]-(n-index)*target);
		int low=min(extraRight,needLeft);
		cost+=1LL*m*low;
		answer=min(answer,cost);
	}
	cout<<answer;

	return 0;
}


//生存的原因引起了生存的原因
#include <bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,a,r,m;
	cin>>n>>a>>r>>m;
	m=min(m,a+r);
	int total=0;
	int input[n];
	for(int i=0;i<n;i++)
		cin>>input[i];
	sort(input,input+n);
	// set<int> st;
	// for(int i=0;i<n;i++) st.insert(input[i]);
	for(int i=0;i<n;i++) total+=input[i];
	int suffixSum[n+1],prefixSum[n+1];
	prefixSum[0]=suffixSum[n]=0;
	for(int i=1;i<=n;i++) prefixSum[i]=prefixSum[i-1]+input[i];
	for(int i=n-1;i>=0;i--) suffixSum[i]=suffixSum[i+1]+input[i];
	int  answer=1e17;
	// for(int i=1;i*i<=total;i++)
	// {
	// 	if(total%i==0)
	// 	{
	// 		st.insert(i);
	// 		st.insert(total/i);
	// 	}
	// }
	int index=0;
	int maxHeight=input[n-1];
	for(int target=0;target<=maxHeight;target++)
	{
		int bricksHere=n*target;
		int cost=0;
		if(bricksHere>total) cost+=a*(bricksHere-total);
		else cost+=r*(total-bricksHere);
		while(index<n && input[index]<target) index++;
		int needLeft=((index)*target-(index?prefixSum[index-1]:0));
		int extraRight=(suffixSum[index]-(n-index)*target);
		int low=min(extraRight,needLeft);
		cost+=1LL*m*low;
		answer=min(answer,cost);
	}
	cout<<answer;

	return 0;
}


//生存的原因引起了生存的原因
#include <bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,a,r,m;
	cin>>n>>a>>r>>m;
	m=min(m,a+r);
	int total=0;
	int input[n];
	for(int i=0;i<n;i++)
		cin>>input[i];
	sort(input,input+n);
	set<int> st;
	for(int i=0;i<n;i++) st.insert(input[i]);
	for(int i=0;i<n;i++) total+=input[i];
	int suffixSum[n+1],prefixSum[n+1];
	prefixSum[0]=input[0];
	suffixSum[n]=0;
	for(int i=1;i<=n;i++) prefixSum[i]=prefixSum[i-1]+input[i];
	for(int i=n-1;i>=0;i--) suffixSum[i]=suffixSum[i+1]+input[i];
	int  answer=1e17;
	int index=0;
	for(int i=0;i<n;i++)
	{
		for(int k=0;k<=10;k++)
		{
			st.insert(min(0LL,input[i]-k));
			st.insert(input[i]+k);
		}
	}
	for(int i=1;i*i<=total;i++)
	{
		if(total%i==0)
		{
			for(int k=0;k<=10;k++)
			{
				st.insert(min(0LL,i-k));
				st.insert(i+k);
				st.insert(min(0LL,total/i-k));
				st.insert(total/i+k);
			}
		}
	}
	for(auto target:st)
	{
		int bricksHere=n*target;
		int cost=0;
		if(bricksHere>total) cost+=a*(bricksHere-total);
		else cost+=r*(total-bricksHere);
		while(index<n && input[index]<target) index++;
		int needLeft=((index)*target-(index?prefixSum[index-1]:0));
		int extraRight=(suffixSum[index]-(n-index)*target);
		int low=min(extraRight,needLeft);
		cost+=1LL*m*low;
		answer=min(answer,cost);
	}
	cout<<answer;

	return 0;
}


//生存的原因引起了生存的原因
#include <bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,a,r,m;
	cin>>n>>a>>r>>m;
	m=min(m,a+r);
	int total=0;
	int input[n];
	for(int i=0;i<n;i++)
		cin>>input[i];
	sort(input,input+n);
	set<int> st;
	for(int i=0;i<n;i++) st.insert(input[i]);
	for(int i=0;i<n;i++) total+=input[i];
	int suffixSum[n+1],prefixSum[n+1];
	prefixSum[0]=input[0];
	suffixSum[n]=0;
	for(int i=1;i<=n;i++) prefixSum[i]=prefixSum[i-1]+input[i];
	for(int i=n-1;i>=0;i--) suffixSum[i]=suffixSum[i+1]+input[i];
	int  answer=1e17;
	int index=0;
	for(int i=0;i<n;i++)
	{
		for(int k=0;k<=100;k++)
		{
			st.insert(min(0LL,input[i]-k));
			st.insert(input[i]+k);
		}
	}
	for(int i=1;i*i<=total;i++)
	{
		if(total%i==0)
		{
			for(int k=0;k<=100;k++)
			{
				st.insert(min(0LL,i-k));
				st.insert(i+k);
				st.insert(min(0LL,total/i-k));
				st.insert(total/i+k);
			}
		}
	}
	for(auto target:st)
	{
		int bricksHere=n*target;
		int cost=0;
		if(bricksHere>total) cost+=a*(bricksHere-total);
		else cost+=r*(total-bricksHere);
		while(index<n && input[index]<target) index++;
		int needLeft=((index)*target-(index?prefixSum[index-1]:0));
		int extraRight=(suffixSum[index]-(n-index)*target);
		int low=min(extraRight,needLeft);
		cost+=1LL*m*low;
		answer=min(answer,cost);
	}
	cout<<answer;

	return 0;
}


//生存的原因引起了生存的原因
#include <bits/stdc++.h>
// #define int long long int
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	long long int a,r,m;
	cin>>n>>a>>r>>m;
	m=min(m,a+r);
	int total=0;
	int input[n];
	for(int i=0;i<n;i++)
		cin>>input[i];
	sort(input,input+n);
	// set<int> st;
	// for(int i=0;i<n;i++) st.insert(input[i]);
	for(int i=0;i<n;i++) total+=input[i];
	int suffixSum[n+1],prefixSum[n+1];
	prefixSum[0]=suffixSum[n]=0;
	for(int i=1;i<=n;i++) prefixSum[i]=prefixSum[i-1]+input[i];
	for(int i=n-1;i>=0;i--) suffixSum[i]=suffixSum[i+1]+input[i];
	long long int  answer=1e17;
	// for(int i=1;i*i<=total;i++)
	// {
	// 	if(total%i==0)
	// 	{
	// 		st.insert(i);
	// 		st.insert(total/i);
	// 	}
	// }
	int index=0;
	int maxHeight=input[n-1];
	for(int target=0;target<=maxHeight;target++)
	{
		int bricksHere=n*target;
		long long int cost=0;
		if(bricksHere>total) cost+=a*(bricksHere-total);
		else cost+=r*(total-bricksHere);
		while(index<n && input[index]<target) index++;
		int needLeft=((index)*target-(index?prefixSum[index-1]:0));
		int extraRight=(suffixSum[index]-(n-index)*target);
		int low=min(extraRight,needLeft);
		cost+=1LL*m*low;
		answer=min(answer,cost);
	}
	cout<<answer;

	return 0;
}


//生存的原因引起了生存的原因
#include <bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,a,r,m;
	cin>>n>>a>>r>>m;
	m=min(m,a+r);
	int total=0;
	int input[n];
	for(int i=0;i<n;i++)
		cin>>input[i];
	sort(input,input+n);
	set<int> st;
	for(int i=0;i<n;i++) st.insert(input[i]);
	for(int i=0;i<n;i++) total+=input[i];
	int suffixSum[n+1],prefixSum[n+1];
	prefixSum[0]=input[0];
	suffixSum[n]=0;
	for(int i=1;i<=n;i++) prefixSum[i]=prefixSum[i-1]+input[i];
	for(int i=n-1;i>=0;i--) suffixSum[i]=suffixSum[i+1]+input[i];
	int  answer=1e17;
	int index=0;
	for(int i=0;i<n;i++)
	{
		for(int k=0;k<=1000;k++)
		{
			st.insert(min(0LL,input[i]-k));
			st.insert(input[i]+k);
		}
	}
	for(int i=1;i*i<=total;i++)
	{
		if(total%i==0)
		{
			for(int k=0;k<=1000;k++)
			{
				st.insert(min(0LL,i-k));
				st.insert(i+k);
				st.insert(min(0LL,total/i-k));
				st.insert(total/i+k);
			}
		}
	}
	for(auto target:st)
	{
		int bricksHere=n*target;
		int cost=0;
		if(bricksHere>total) cost+=a*(bricksHere-total);
		else cost+=r*(total-bricksHere);
		while(index<n && input[index]<target) index++;
		int needLeft=((index)*target-(index?prefixSum[index-1]:0));
		int extraRight=(suffixSum[index]-(n-index)*target);
		int low=min(extraRight,needLeft);
		cost+=1LL*m*low;
		answer=min(answer,cost);
	}
	cout<<answer;

	return 0;
}


//生存的原因引起了生存的原因
#include <bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,a,r,m;
	cin>>n>>a>>r>>m;
	m=min(m,a+r);
	int total=0;
	int input[n];
	for(int i=0;i<n;i++)
		cin>>input[i];
	sort(input,input+n);
	set<int> st;
	for(int i=0;i<n;i++) st.insert(input[i]);
	for(int i=0;i<n;i++) total+=input[i];
	int suffixSum[n+1],prefixSum[n+1];
	prefixSum[0]=suffixSum[n]=0;
	for(int i=1;i<=n;i++) prefixSum[i]=prefixSum[i-1]+input[i];
	for(int i=n-1;i>=0;i--) suffixSum[i]=suffixSum[i+1]+input[i];
	int  answer=1e17;
	for(int i=1;i*i<=total;i++)
	{
		if(total%i==0)
		{
			st.insert(i);
			st.insert(total/i);
		}
	}
	int index=0;
	for(auto target:st)
	{
		int bricksHere=n*target;
		int cost=0;
		if(bricksHere>total) cost+=a*(bricksHere-total);
		else cost+=r*(total-bricksHere);
		while(index<n && input[index]<target) index++;
		int needLeft=((index)*target-(index?prefixSum[index-1]:0));
		int extraRight=(suffixSum[index]-(n-index)*target);
		int low=min(extraRight,needLeft);
		cost+=m*low;
		answer=min(answer,cost);
	}
	cout<<answer;

	return 0;
}


//生存的原因引起了生存的原因
#include <bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,a,r,m;
	cin>>n>>a>>r>>m;
	m=min(m,a+r);
	int total=0;
	int input[n];
	for(int i=0;i<n;i++)
		cin>>input[i];
	sort(input,input+n);
	for(int i=0;i<n;i++) total+=input[i];
	int suffixSum[n+1],prefixSum[n+1];
	prefixSum[0]=input[0];
	suffixSum[n]=0;
	for(int i=1;i<=n;i++) prefixSum[i]=prefixSum[i-1]+input[i];
	for(int i=n-1;i>=0;i--) suffixSum[i]=suffixSum[i+1]+input[i];
	int  answer=1e17;
	int index=0;
	int maxHeight=input[n-1];
	for(int target=0;target<=maxHeight;target++)
	{
		int bricksHere=n*target;
		int cost=0;
		if(bricksHere>total) cost+=a*(bricksHere-total);
		else cost+=r*(total-bricksHere);
		while(index<n && input[index]<target) index++;
		int needLeft=((index)*target-(index?prefixSum[index-1]:0));
		int extraRight=(suffixSum[index]-(n-index)*target);
		int low=min(extraRight,needLeft);
		cost+=1LL*m*low;
		answer=min(answer,cost);
	}
	cout<<answer;

	return 0;
}


//生存的原因引起了生存的原因
#include <bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,a,r,m;
	cin>>n>>a>>r>>m;
	m=min(m,a+r);
	int total=0;
	int input[n];
	for(int i=0;i<n;i++)
		cin>>input[i];
	sort(input,input+n);
	set<int> st;
	for(int i=0;i<n;i++) st.insert(input[i]);
	for(int i=0;i<n;i++) total+=input[i];
	int suffixSum[n+1],prefixSum[n+1];
	prefixSum[0]=input[0];
	suffixSum[n]=0;
	for(int i=1;i<=n;i++) prefixSum[i]=prefixSum[i-1]+input[i];
	for(int i=n-1;i>=0;i--) suffixSum[i]=suffixSum[i+1]+input[i];
	int  answer=1e17;
	int index=0;
	for(int i=1;i*i<=total;i++)
	{
		if(total%i==0)
		{
			st.insert(i);
			st.insert(i+1);
			st.insert(i-1);
			st.insert(total/i);
			st.insert(total/i+1);
			st.insert(total/i-1);
		}
	}
	for(auto target:st)
	{
		int bricksHere=n*target;
		int cost=0;
		if(bricksHere>total) cost+=a*(bricksHere-total);
		else cost+=r*(total-bricksHere);
		while(index<n && input[index]<target) index++;
		int needLeft=((index)*target-(index?prefixSum[index-1]:0));
		int extraRight=(suffixSum[index]-(n-index)*target);
		int low=min(extraRight,needLeft);
		cost+=1LL*m*low;
		answer=min(answer,cost);
	}
	cout<<answer;

	return 0;
}


//生存的原因引起了生存的原因
#include <bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,a,r,m;
	cin>>n>>a>>r>>m;
	m=min(m,a+r);
	int total=0;
	int input[n];
	for(int i=0;i<n;i++)
		cin>>input[i];
	sort(input,input+n);
	set<int> st;
	for(int i=0;i<n;i++) st.insert(input[i]);
	for(int i=0;i<n;i++) total+=input[i];
	int suffixSum[n+1],prefixSum[n+1];
	prefixSum[0]=input[0];
	suffixSum[n]=0;
	for(int i=1;i<=n;i++) prefixSum[i]=prefixSum[i-1]+input[i];
	for(int i=n-1;i>=0;i--) suffixSum[i]=suffixSum[i+1]+input[i];
	int  answer=1e17;
	int index=0;
	for(int i=0;i<n;i++)
	{
		for(int k=0;k<=10000;k++)
		{
			st.insert(min(0LL,input[i]-k));
			st.insert(input[i]+k);
		}
	}
	for(int i=1;i*i<=total;i++)
	{
		if(total%i==0)
		{
			for(int k=0;k<=10000;k++)
			{
				st.insert(min(0LL,i-k));
				st.insert(i+k);
				st.insert(min(0LL,total/i-k));
				st.insert(total/i+k);
			}
		}
	}
	for(auto target:st)
	{
		int bricksHere=n*target;
		int cost=0;
		if(bricksHere>total) cost+=a*(bricksHere-total);
		else cost+=r*(total-bricksHere);
		while(index<n && input[index]<target) index++;
		int needLeft=((index)*target-(index?prefixSum[index-1]:0));
		int extraRight=(suffixSum[index]-(n-index)*target);
		int low=min(extraRight,needLeft);
		cost+=1LL*m*low;
		answer=min(answer,cost);
	}
	cout<<answer;

	return 0;
}


//生存的原因引起了生存的原因
#include <bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,a,r,m;
	cin>>n>>a>>r>>m;
	m=min(m,a+r);
	int total=0;
	int input[n];
	for(int i=0;i<n;i++)
		cin>>input[i];
	sort(input,input+n);
	for(int i=0;i<n;i++) total+=input[i];
	int suffixSum[n+1],prefixSum[n+1];
	prefixSum[0]=input[0];
	suffixSum[n]=0;
	for(int i=1;i<=n;i++) prefixSum[i]=prefixSum[i-1]+input[i];
	for(int i=n-1;i>=0;i--) suffixSum[i]=suffixSum[i+1]+input[i];
	int  answer=1e17;
	auto costTarget=[&](int target)
	{
		int bricksHere=n*target;
		int cost=0;
		if(bricksHere>total) cost+=a*(bricksHere-total);
		else cost+=r*(total-bricksHere);
		int index=0,l1=0,r1=n-1;
		while(l1<=r1)
		{
			int midd=(l1+r1)/2;
			if(input[midd]>=target)
			{
				r1=midd-1;
				index=midd;
			}
			else
				l1=midd+1;
		}
		while(index<n && input[index]<target) index++;
		int needLeft=((index)*target-(index?prefixSum[index-1]:0));
		int extraRight=(suffixSum[index]-(n-index)*target);
		int low=min(extraRight,needLeft);
		cost+=1LL*m*low;
		answer=min(answer,cost);
		return cost;
	};
	int l1=0,r1=1e9;
	//write ternary search
	while(l1<r1)
	{
		int midd=(l1+r1)/2;
		if(costTarget(midd)<costTarget(midd+1))
			r1=midd;
		else
			l1=midd+1;
	}
	// cout<<answer;
	cout<<costTarget(l1);

	return 0;
}


//生存的原因引起了生存的原因
#include <bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,a,r,m;
	cin>>n>>a>>r>>m;
	m=min(m,a+r);
	int total=0;
	int input[n];
	for(int i=0;i<n;i++)
		cin>>input[i];
	sort(input,input+n);
	set<int> st;
	for(int i=0;i<n;i++) st.insert(input[i]);
	for(int i=0;i<n;i++) total+=input[i];
	int suffixSum[n+1],prefixSum[n+1];
	prefixSum[0]=input[0];
	suffixSum[n]=0;
	for(int i=1;i<=n;i++) prefixSum[i]=prefixSum[i-1]+input[i];
	for(int i=n-1;i>=0;i--) suffixSum[i]=suffixSum[i+1]+input[i];
	int  answer=1e17;
	int index=0;
	for(int i=0;i<n;i++)
	{
		for(int k=0;k<=30000;k++)
		{
			st.insert(min(0LL,input[i]-k));
			st.insert(input[i]+k);
		}
	}
	for(int i=1;i*i<=total;i++)
	{
		if(total%i==0)
		{
			for(int k=0;k<=30000;k++)
			{
				st.insert(min(0LL,i-k));
				st.insert(i+k);
				st.insert(min(0LL,total/i-k));
				st.insert(total/i+k);
			}
		}
	}
	for(auto target:st)
	{
		int bricksHere=n*target;
		int cost=0;
		if(bricksHere>total) cost+=a*(bricksHere-total);
		else cost+=r*(total-bricksHere);
		while(index<n && input[index]<target) index++;
		int needLeft=((index)*target-(index?prefixSum[index-1]:0));
		int extraRight=(suffixSum[index]-(n-index)*target);
		int low=min(extraRight,needLeft);
		cost+=1LL*m*low;
		answer=min(answer,cost);
	}
	cout<<answer;

	return 0;
}


//生存的原因引起了生存的原因
#include <bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,a,r,m;
	cin>>n>>a>>r>>m;
	m=min(m,a+r);
	int total=0;
	int input[n];
	for(int i=0;i<n;i++)
		cin>>input[i];
	sort(input,input+n);
	set<int> st;
	for(int i=0;i<n;i++) st.insert(input[i]);
	for(int i=0;i<n;i++) total+=input[i];
	int suffixSum[n+1],prefixSum[n+1];
	prefixSum[0]=input[0];
	suffixSum[n]=0;
	for(int i=1;i<=n;i++) prefixSum[i]=prefixSum[i-1]+input[i];
	for(int i=n-1;i>=0;i--) suffixSum[i]=suffixSum[i+1]+input[i];
	int  answer=1e17;
	int index=0;
	for(int i=0;i<n;i++)
	{
		for(int k=0;k<=40000;k++)
		{
			st.insert(min(0LL,input[i]-k));
			st.insert(input[i]+k);
		}
	}
	for(int i=1;i*i<=total;i++)
	{
		if(total%i==0)
		{
			for(int k=0;k<=40000;k++)
			{
				st.insert(min(0LL,i-k));
				st.insert(i+k);
				st.insert(min(0LL,total/i-k));
				st.insert(total/i+k);
			}
		}
	}
	for(auto target:st)
	{
		int bricksHere=n*target;
		int cost=0;
		if(bricksHere>total) cost+=a*(bricksHere-total);
		else cost+=r*(total-bricksHere);
		while(index<n && input[index]<target) index++;
		int needLeft=((index)*target-(index?prefixSum[index-1]:0));
		int extraRight=(suffixSum[index]-(n-index)*target);
		int low=min(extraRight,needLeft);
		cost+=1LL*m*low;
		answer=min(answer,cost);
	}
	cout<<answer;

	return 0;
}


//生存的原因引起了生存的原因
#include <bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,a,r,m;
	cin>>n>>a>>r>>m;
	m=min(m,a+r);
	int total=0;
	int input[n];
	for(int i=0;i<n;i++)
		cin>>input[i];
	sort(input,input+n);
	set<int> st;
	for(int i=0;i<n;i++) st.insert(input[i]);
	for(int i=0;i<n;i++) total+=input[i];
	int suffixSum[n+1],prefixSum[n+1];
	prefixSum[0]=input[0];
	suffixSum[n]=0;
	for(int i=1;i<=n;i++) prefixSum[i]=prefixSum[i-1]+input[i];
	for(int i=n-1;i>=0;i--) suffixSum[i]=suffixSum[i+1]+input[i];
	int  answer=1e17;
	int index=0;
	for(int i=1;i*i<=total;i++)
	{
		if(total%i==0)
		{
			st.insert(i);
			st.insert(total/i);
		}
	}
	for(auto target:st)
	{
		int bricksHere=n*target;
		int cost=0;
		if(bricksHere>total) cost+=a*(bricksHere-total);
		else cost+=r*(total-bricksHere);
		while(index<n && input[index]<target) index++;
		int needLeft=((index)*target-(index?prefixSum[index-1]:0));
		int extraRight=(suffixSum[index]-(n-index)*target);
		int low=min(extraRight,needLeft);
		cost+=1LL*m*low;
		answer=min(answer,cost);
	}
	cout<<answer;

	return 0;
}


//Solution using Gradient Search
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) ll t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf LLONG_MAX
ll mult(ll a,ll b, ll p=mod){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll fpow(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1LL)
            res = (res*x) % mod;
        y = y>>1LL;
        x = (x*x) % mod;
    }
    return res;
}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2);}
bool sa(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second<b.second);}
bool fd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.first>b.first);}
bool sd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second>b.second);}
ll dx[4]={0,0,1,-1};
ll dy[4]={1,-1,0,0};
bool valid(ll x,ll y,ll n,ll m){
    if(x<0 || y<0){
       return false;
   }
   else if(x>=n || y>=m){
       return false;
   }
   else
   return true;
}
ll arr[100005],pref[100005];
ll n,m,a,r;
ll solve(ll h){
    ll ind,lower,higher,moves;
    ind=upper_bound(arr,arr+n,h)-arr;
    ind--;
    lower=(h*(ind+1))-pref[ind];
    higher=(pref[n-1]-pref[ind])-(h*(n-ind-1));
    moves=min(lower,higher);
    // cout<<lower<<" "<<higher<<" ";
    lower-=moves;
    higher-=moves;
    // cout<<a+r<<" ";
    m=min(m,(a+r));
    // cout<<m<<"\n";
    return (m*moves+lower*a+higher*r);
}

int main(){
    fio;
    ll mid,L,R,ans=inf;
    cin>>n>>a>>r>>m;
    ll a[n+5];
    fr(i,0,n){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    pref[0]=arr[0];
    fr(i,1,n){
        pref[i]=arr[i]+pref[i-1];
    }
    L=arr[0];R=arr[n-1];
    while(L<R){
        mid=(L+R)/2;
        if(solve(mid)<solve(mid+1)){
            R=mid;
        }
        else{
            L=mid+1;
        }
    }
    ans=solve(L);
    cout<<ans<<"\n";
    rr;
}


//Solution using Gradient Search
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) ll t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf LLONG_MAX
ll mult(ll a,ll b, ll p=mod){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll fpow(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1LL)
            res = (res*x) % mod;
        y = y>>1LL;
        x = (x*x) % mod;
    }
    return res;
}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2);}
bool sa(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second<b.second);}
bool fd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.first>b.first);}
bool sd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second>b.second);}
ll dx[4]={0,0,1,-1};
ll dy[4]={1,-1,0,0};
bool valid(ll x,ll y,ll n,ll m){
    if(x<0 || y<0){
       return false;
   }
   else if(x>=n || y>=m){
       return false;
   }
   else
   return true;
}
ll arr[100005],pref[100005];
ll n,m,a,r;
ll solve(ll h){
    ll ind,lower,higher,moves;
    ind=upper_bound(arr,arr+n,h)-arr;
    ind--;
    lower=(h*(ind+1))-pref[ind];
    higher=(pref[n-1]-pref[ind])-(h*(n-ind-1));
    moves=min(lower,higher);
    // cout<<lower<<" "<<higher<<" ";
    lower-=moves;
    higher-=moves;
    // cout<<a+r<<" ";
    m=min(m,(a+r));
    // cout<<m<<"\n";
    return (m*moves+lower*a+higher*r);
}

int main(){
    fio;
    ll mid,L,R,ans=inf;
    cin>>n>>a>>r>>m;
    ll a[n+5];
    fr(i,0,n){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    pref[0]=arr[0];
    fr(i,1,n){
        pref[i]=arr[i]+pref[i-1];
    }
    L=arr[0];R=arr[n-1];
    while(L<R){
        mid=(L+R)/2;
        if(solve(mid)<solve(mid+1)){
            R=mid;
        }
        else{
            L=mid+1;
        }
    }

    // ans=solve(L);
    cout<<solve(R)<<"\n";
    // cout<<ans<<"\n";
    rr;
}


//Solution using Ternary Search
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) ll t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf LLONG_MAX
ll mult(ll a,ll b, ll p=mod){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll fpow(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1LL)
            res = (res*x) % mod;
        y = y>>1LL;
        x = (x*x) % mod;
    }
    return res;
}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2);}
bool sa(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second<b.second);}
bool fd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.first>b.first);}
bool sd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second>b.second);}
ll dx[4]={0,0,1,-1};
ll dy[4]={1,-1,0,0};
bool valid(ll x,ll y,ll n,ll m){
    if(x<0 || y<0){
       return false;
   }
   else if(x>=n || y>=m){
       return false;
   }
   else
   return true;
}
ll arr[100005],pref[100005];
ll n,m,a,r;
ll solve(ll h){
    ll ind,lower,higher,moves;
    ind=upper_bound(arr,arr+n,h)-arr;
    ind--;
    lower=(h*(ind+1))-pref[ind];
    higher=(pref[n-1]-pref[ind])-(h*(n-ind-1));
    moves=min(lower,higher);
    // cout<<lower<<" "<<higher<<" ";
    lower-=moves;
    higher-=moves;
    // cout<<a+r<<" ";
    m=min(m,(a+r));
    // cout<<m<<"\n";
    return (m*moves+lower*a+higher*r);
}

int main(){
    fio;
    ll m1,m2,L,R,ans=inf;
    cin>>n>>a>>r>>m;
    ll a[n+5];
    fr(i,0,n){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    pref[0]=arr[0];
    fr(i,1,n){
        pref[i]=arr[i]+pref[i-1];
    }
    L=arr[0];R=arr[n-1];
    while((R-L)>3){
        m1=L+(R-L)/3;
        m2=R-(R-L)/3;
        if(solve(m1)<solve(m2)){
            R=m2;
        }
        else{
            L=m1;
        }
    }
    fr(i,L,R+1){
        // cout<<solve(i)<<" ";
        ans=min(ans,solve(i));
    }
    cout<<ans<<"\n";
    rr;
}


//Solution using Ternary Search
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) ll t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf LLONG_MAX
ll mult(ll a,ll b, ll p=mod){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll fpow(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1LL)
            res = (res*x) % mod;
        y = y>>1LL;
        x = (x*x) % mod;
    }
    return res;
}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2);}
bool sa(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second<b.second);}
bool fd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.first>b.first);}
bool sd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second>b.second);}
ll dx[4]={0,0,1,-1};
ll dy[4]={1,-1,0,0};
bool valid(ll x,ll y,ll n,ll m){
    if(x<0 || y<0){
       return false;
   }
   else if(x>=n || y>=m){
       return false;
   }
   else
   return true;
}
ll arr[100005],pref[100005];
ll n,m,a,r;
ll solve(ll h){
    ll ind,lower,higher,moves;
    ind=upper_bound(arr,arr+n,h)-arr;
    ind--;
    lower=(h*(ind+1))-pref[ind];
    higher=(pref[n-1]-pref[ind])-(h*(n-ind-1));
    moves=min(lower,higher);
    // cout<<lower<<" "<<higher<<" ";
    lower-=moves;
    higher-=moves;
    // cout<<a+r<<" ";
    m=min(m,(a+r));
    // cout<<m<<"\n";
    return (m*moves+lower*a+higher*r);
}

int main(){
    fio;
    ll m1,m2,L,R,ans=inf;
    cin>>n>>a>>r>>m;
    ll a[n+5];
    fr(i,0,n){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    pref[0]=arr[0];
    fr(i,1,n){
        pref[i]=arr[i]+pref[i-1];
    }
    L=arr[0];R=arr[n-1];
    while((R-L)>5){
        m1=L+(R-L)/3;
        m2=R-(R-L)/3;
        if(solve(m1)<solve(m2)){
            R=m2;
        }
        else{
            L=m1;
        }
    }
    fr(i,L,R+1){
        // cout<<solve(i)<<" ";
        ans=min(ans,solve(i));
    }
    cout<<ans<<"\n";
    rr;
}


//Solution using Ternary Search
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) ll t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf LLONG_MAX
ll mult(ll a,ll b, ll p=mod){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll fpow(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1LL)
            res = (res*x) % mod;
        y = y>>1LL;
        x = (x*x) % mod;
    }
    return res;
}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2);}
bool sa(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second<b.second);}
bool fd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.first>b.first);}
bool sd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second>b.second);}
ll dx[4]={0,0,1,-1};
ll dy[4]={1,-1,0,0};
bool valid(ll x,ll y,ll n,ll m){
    if(x<0 || y<0){
       return false;
   }
   else if(x>=n || y>=m){
       return false;
   }
   else
   return true;
}
ll arr[100005],pref[100005];
ll n,m,a,r;
ll solve(ll h){
    ll ind,lower,higher,moves;
    ind=upper_bound(arr,arr+n,h)-arr;
    ind--;
    lower=(h*(ind+1))-pref[ind];
    higher=(pref[n-1]-pref[ind])-(h*(n-ind-1));
    moves=min(lower,higher);
    // cout<<lower<<" "<<higher<<" ";
    lower-=moves;
    higher-=moves;
    // cout<<a+r<<" ";
    m=min(m,(a+r));
    // cout<<m<<"\n";
    return (m*moves+lower*a+higher*r);
}

int main(){
    fio;
    ll m1,m2,L,R,ans=inf;
    cin>>n>>a>>r>>m;
    ll a[n+5];
    fr(i,0,n){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    pref[0]=arr[0];
    fr(i,1,n){
        pref[i]=arr[i]+pref[i-1];
    }
    L=arr[0];R=arr[n-1];
    while((R-L)>1){
        m1=L+(R-L)/3;
        m2=R-(R-L)/3;
        if(solve(m1)<solve(m2)){
            R=m2;
        }
        else{
            L=m1;
        }
    }
    fr(i,L,R+1){
        // cout<<solve(i)<<" ";
        ans=min(ans,solve(i));
    }
    cout<<ans<<"\n";
    rr;
}


//Solution using Ternary Search
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) ll t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf LLONG_MAX
ll mult(ll a,ll b, ll p=mod){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll fpow(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1LL)
            res = (res*x) % mod;
        y = y>>1LL;
        x = (x*x) % mod;
    }
    return res;
}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2);}
bool sa(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second<b.second);}
bool fd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.first>b.first);}
bool sd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second>b.second);}
ll dx[4]={0,0,1,-1};
ll dy[4]={1,-1,0,0};
bool valid(ll x,ll y,ll n,ll m){
    if(x<0 || y<0){
       return false;
   }
   else if(x>=n || y>=m){
       return false;
   }
   else
   return true;
}
ll arr[100005],pref[100005];
ll n,m,a,r;
ll solve(ll h){
    ll ind,lower,higher,moves;
    ind=upper_bound(arr,arr+n,h)-arr;
    ind--;
    lower=(h*(ind+1))-pref[ind];
    higher=(pref[n-1]-pref[ind])-(h*(n-ind-1));
    moves=min(lower,higher);
    // cout<<lower<<" "<<higher<<" ";
    lower-=moves;
    higher-=moves;
    // cout<<a+r<<" ";
    m=min(m,(a+r));
    // cout<<m<<"\n";
    return (m*moves+lower*a+higher*r);
}

int main(){
    fio;
    ll m1,m2,L,R,ans=inf;
    cin>>n>>a>>r>>m;
    ll a[n+5];
    fr(i,0,n){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    pref[0]=arr[0];
    fr(i,1,n){
        pref[i]=arr[i]+pref[i-1];
    }
    L=arr[0];R=arr[n-1];
    while((R-L)>2){
        m1=L+(R-L)/3;
        m2=R-(R-L)/3;
        if(solve(m1)<solve(m2)){
            R=m2;
        }
        else{
            L=m1;
        }
    }
    fr(i,L,R+1){
        // cout<<solve(i)<<" ";
        ans=min(ans,solve(i));
    }
    cout<<ans<<"\n";
    rr;
}


//Solution using Ternary Search
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) ll t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf LLONG_MAX
ll mult(ll a,ll b, ll p=mod){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll fpow(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1LL)
            res = (res*x) % mod;
        y = y>>1LL;
        x = (x*x) % mod;
    }
    return res;
}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2);}
bool sa(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second<b.second);}
bool fd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.first>b.first);}
bool sd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second>b.second);}
ll dx[4]={0,0,1,-1};
ll dy[4]={1,-1,0,0};
bool valid(ll x,ll y,ll n,ll m){
    if(x<0 || y<0){
       return false;
   }
   else if(x>=n || y>=m){
       return false;
   }
   else
   return true;
}
ll arr[100005],pref[100005];
ll n,m,a,r;
ll solve(ll h){
    ll ind,lower,higher,moves;
    ind=upper_bound(arr,arr+n,h)-arr;
    ind--;
    lower=(h*(ind+1))-pref[ind];
    higher=(pref[n-1]-pref[ind])-(h*(n-ind-1));
    moves=min(lower,higher);
    // cout<<lower<<" "<<higher<<" ";
    lower-=moves;
    higher-=moves;
    // cout<<a+r<<" ";
    m=min(m,(a+r));
    // cout<<m<<"\n";
    return (m*moves+lower*a+higher*r);
}

int main(){
    fio;
    ll m1,m2,L,R,ans=inf;
    cin>>n>>a>>r>>m;
    ll a[n+5];
    fr(i,0,n){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    pref[0]=arr[0];
    fr(i,1,n){
        pref[i]=arr[i]+pref[i-1];
    }
    L=arr[0];R=arr[n-1];
    while((R-L)>(ll)1e5){
        m1=L+(R-L)/3;
        m2=R-(R-L)/3;
        if(solve(m1)<solve(m2)){
            R=m2;
        }
        else{
            L=m1;
        }
    }
    fr(i,L,R+1){
        // cout<<solve(i)<<" ";
        ans=min(ans,solve(i));
    }
    cout<<ans<<"\n";
    rr;
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
#define int long long
const int inf = 1e18;
const int N = 1e5 + 5;
int n,a,r,m;
int arr[N];

int cost(int h){
	int ans = 0;
	int ad = 0,rm = 0;
	for(int i=0;i<n;i++){
		if(arr[i]>h)
			rm+=(arr[i]-h);
		else
			ad+=(h-arr[i]);
	}
	int tt = min(ad,rm);
	ans = tt*min(m,a+r);
	ad -= tt;
	rm -= tt;
	ans += ad*a + rm*r;
	return ans;
}

int32_t main() {
	cin>>n>>a>>r>>m;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	int l = 0,r = 1e9,ans = inf;
	while(r-l>100){
		int m1 = (2*l+r)/3;
		int m2 = (l+2*r)/3;
		int t1 = cost(m1);
		int t2 = cost(m2);
		if(t1<t2)
			r = m2;
		else
			l = m1;
	}
	//cout<<l<<" "<<r<<endl;
	for(int i=l;i<=r;i++)
		ans = min(ans,cost(i));
	cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
#define int long long
const int inf = 1e18;
const int N = 1e5 + 5;
int n,a,r,m;
int arr[N];

int cost(int h){
	int ans = 0;
	int ad = 0,rm = 0;
	for(int i=0;i<n;i++){
		if(arr[i]>h)
			rm+=(arr[i]-h);
		else
			ad+=(h-arr[i]);
	}
	int take = min(ad,rm);
	ans = take*min(m,a+r);
	ad -= take; rm -= take;
	ans += ad*a + rm*r;
	return ans;
}

int ternary_search(int l,int r){
	while(r-l>2){
		int m1 = (2 * l + r) / 3;
		int m2 = (l + 2 * r) / 3;
		int t1 = cost(m1);
		int t2 = cost(m2);
		if(t1<=t2)
			r = m2;
		else
			l = m1;
	}
	int ans = cost(l);
	for(int i=l+1;i<=r;i++)
		ans = min(ans,cost(i));
	return ans;
}

int32_t main() {
	cin>>n>>a>>r>>m;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	cout<<ternary_search(0,1e9)<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
#define int long long
const int inf = 1e18;
const int N = 1e5 + 5;
int n,a,r,m;
int arr[N];

int cost(int h){
	int ans = 0;
	int ad = 0,rm = 0;
	for(int i=0;i<n;i++){
		if(arr[i]>h)
			rm+=(arr[i]-h);
		else
			ad+=(h-arr[i]);
	}
	int tt = min(ad,rm);
	ans = tt*min(m,a+r);
	ad -= tt;
	rm -= tt;
	ans += ad*a + rm*r;
	return ans;
}

int32_t main() {
	cin>>n>>a>>r>>m;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	int l = 0,r = 1e9,ans = inf;
	while(r-l>100){
		int m1 = l + (r - l)/3;
		int m2 = r - (r - l)/3;
		int t1 = cost(m1);
		int t2 = cost(m2);
		if(t1<t2)
			r = m1;
		else
			l = m2;
	}
	//cout<<l<<" "<<r<<endl;
	for(int i=l;i<=r;i++)
		ans = min(ans,cost(i));
	cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
#define int long long
const int inf = 1e9;
const int N = 1e5 + 5;
int n,a,r,m;
int arr[N];

int cost(int h){
	int ans = 0;
	int ad = 0,rm = 0;
	for(int i=0;i<n;i++){
		if(arr[i]>h)
			rm+=(arr[i]-h);
		else
			ad+=(h-arr[i]);
	}
	int tt = min(ad,rm);
	ans = tt*min(m,a+r);
	ad -= tt;
	rm -= tt;
	ans += ad*a + rm*r;
	return ans;
}

int32_t main() {
	cin>>n>>a>>r>>m;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	int l = 0,r = 1e9,ans = inf;
	while(r-l>100){
		int m1 = l + (r - l)/3;
		int m2 = r - (r - l)/3;
		int t1 = cost(m1);
		int t2 = cost(m2);
		if(t1<t2)
			r = m1;
		else
			l = m2;
	}
	//cout<<l<<" "<<r<<endl;
	for(int i=l;i<=r;i++)
		ans = min(ans,cost(i));
	cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
#define int long long
const int inf = 1e18;
const int N = 1e5 + 5;
int n,a,r,m;
int arr[N];

int cost(int h){
	int ans = 0;
	int ad = 0,rm = 0;
	for(int i=0;i<n;i++){
		if(arr[i]>h)
			rm+=(arr[i]-h);
		else
			ad+=(h-arr[i]);
	}
	int take = min(ad,rm);
	ans = take*min(m,a+r);
	ad -= take; rm -= take;
	ans += ad*a + rm*r;
	return ans;
}

int ternary_search(int l,int r){
	while(r-l>2){
		int m1 = l + (r -l) / 3;
		int m2 = r - (r-l) / 3;
		int t1 = cost(m1);
		int t2 = cost(m2);
		if(t1<=t2)
			r = m2;
		else
			l = m1;
	}
	int ans = cost(l);
	for(int i=l+1;i<=r;i++)
		ans = min(ans,cost(i));
	return ans;
}

int32_t main() {
	cin>>n>>a>>r>>m;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	cout<<ternary_search(0,1e9)<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
#define int long long
const int inf = 1e18;
const int N = 1e5 + 5;
int n,a,r,m;
int arr[N];

int cost(int h){
	int ans = 0;
	int ad = 0,rm = 0;
	for(int i=0;i<n;i++){
		if(arr[i]>h)
			rm+=(arr[i]-h);
		else
			ad+=(h-arr[i]);
	}
	int tt = min(ad,rm);
	ans = tt*min(m,a+r);
	ad -= tt;
	rm -= tt;
	ans += ad*a + rm*r;
	return ans;
}

int32_t main() {
	cin>>n>>a>>r>>m;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	int l = 0,r = 1e9,ans = inf;
	while(r-l>1000){
		int m1 = l + (r - l)/3;
		int m2 = r - (r - l)/3;
		int t1 = cost(m1);
		int t2 = cost(m2);
		if(t1<t2)
			r = m1;
		else
			l = m2;
	}
	//cout<<l<<" "<<r<<endl;
	for(int i=l;i<=r;i++)
		ans = min(ans,cost(i));
	cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
#define int long long
const int inf = 1e18;
const int N = 1e5 + 5;
int n,a,r,m;
int arr[N];

int cost(int h){
	int ans = 0;
	int ad = 0,rm = 0;
	for(int i=0;i<n;i++){
		if(arr[i]>h)
			rm+=(arr[i]-h);
		else
			ad+=(h-arr[i]);
	}
	int tt = min(ad,rm);
	ans = tt*min(m,a+r);
	ad -= tt;
	rm -= tt;
	ans += ad*a + rm*r;
	return ans;
}

int32_t main() {
	cin>>n>>a>>r>>m;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	int l = 0,r = 1e9,ans = inf;
	while(r-l>100){
		int m1 = (2*l+r)/3;
		int m2 = (l+2*r)/3;
		int t1 = cost(m1);
		int t2 = cost(m2);
		if(t1<t2)
			r = m1;
		else
			l = m2;
	}
	//cout<<l<<" "<<r<<endl;
	for(int i=l;i<=r;i++)
		ans = min(ans,cost(i));
	cout<<ans<<endl;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second

using namespace std;

pair<ll,ll> fun(ll x,ll h[],ll n){
	ll r=0,a=0;
	f(i,n){
		if(h[i]>x)
			r=r+(h[i]-x);
		else
			a = a + (x-h[i]);
	}
	return {a,r};
}

void test(){
	ll n,a,r,m;
	cin>>n>>a>>r>>m;
	ll h[n];
	f(i,n)cin>>h[i];
	ll high = 0,low = 1e9 + 2;
	f(i,n){
		high = max(high,h[i]);
		low = min(low,h[i]);
	}

	// case first move is efficient
	pair<ll,ll> qq = fun(low,h,n);
	ll answer  = qq.F*a + qq.S*r;
	ll temp = min(qq.F,qq.S)*m;
	if(qq.F>qq.S)temp = temp +(qq.F- min(qq.F,qq.S))*a;
	else temp = temp + (qq.S- min(qq.F,qq.S))*r;
	answer = min(answer,temp);
	qq = fun(high,h,n);
	answer = min(answer,qq.F*a + qq.S*r);
	temp = min(qq.F,qq.S)*m;
	if(qq.F>qq.S)temp = temp + (qq.F- min(qq.F,qq.S))*a;
	else temp = temp + (qq.S- min(qq.F,qq.S))*r;
	answer = min(answer,temp);

	{
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = m*pp.F + (pp.S-pp.F)*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}else{
					ll tcal = m*pp.S + (pp.F-pp.S)*a;
					ta = min(ta,tcal);
					hil = mid-1;
				}
			}
			answer = min(answer,ta);
		}

		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = m*pp.F + (pp.S-pp.F)*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}else{
					ll tcal = m*pp.S + (pp.F-pp.S)*a;
					ta = min(ta,tcal);
					lol = mid+1;
				}
			}
			answer = min(ta,answer); //ta;
		}
	}

	{
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}else{
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}
			}
			answer = min(answer,ta); //ta;
		}
		//
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}else{
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}
			}
			answer = min(answer,ta);
		}
	}
	{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = m*pp.F + (pp.S-pp.F)*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}else{
					ll tcal = m*pp.S + (pp.F-pp.S)*a;
					ta = min(ta,tcal);
					lol = mid+1;
				}
			}
			answer = min(answer,ta);
		}
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = m*pp.F + (pp.S-pp.F)*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}else{
					ll tcal = m*pp.S + (pp.F-pp.S)*a;
					ta = min(ta,tcal);
					hil = mid-1;
				}
			}
			answer = min(answer,ta);
		}
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}else{
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}
			}
			answer = min(answer,ta);
		}
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}else{
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}
			}
			answer = min(answer,ta);
		}

	cout<<answer<<"\n";

}

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		test();
	}
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second

using namespace std;

pair<ll,ll> fun(ll x,ll h[],ll n){
	ll r=0,a=0;
	f(i,n){
		if(h[i]>x)
			r=r+(h[i]-x);
		else
			a = a + (x-h[i]);
	}
	return {a,r};
}

void test(){
	ll n,a,r,m;
	cin>>n>>a>>r>>m;
	ll h[n];
	f(i,n)cin>>h[i];
	ll high = 0,low = 1e9 + 2;
	f(i,n){
		high = max(high,h[i]);
		low = min(low,h[i]);
	}

	// case first move is efficient
	pair<ll,ll> qq = fun(low,h,n);
	ll answer  = qq.F*a + qq.S*r;
	qq = fun(high,h,n);
	answer = min(answer,qq.F*a + qq.S*r);

	{
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = m*pp.F + (pp.S-pp.F)*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}else{
					ll tcal = m*pp.S + (pp.F-pp.S)*a;
					ta = min(ta,tcal);
					hil = mid-1;
				}
			}
			answer = min(answer,ta);
		}

		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = m*pp.F + (pp.S-pp.F)*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}else{
					ll tcal = m*pp.S + (pp.F-pp.S)*a;
					ta = min(ta,tcal);
					lol = mid+1;
				}
			}
			answer = min(ta,answer); //ta;
		}
	}

	{
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}else{
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}
			}
			answer = min(answer,ta); //ta;
		}
		//
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}else{
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}
			}
			answer = min(answer,ta);
		}
	}
	{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = m*pp.F + (pp.S-pp.F)*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}else{
					ll tcal = m*pp.S + (pp.F-pp.S)*a;
					ta = min(ta,tcal);
					lol = mid+1;
				}
			}
			answer = min(answer,ta);
		}
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = m*pp.F + (pp.S-pp.F)*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}else{
					ll tcal = m*pp.S + (pp.F-pp.S)*a;
					ta = min(ta,tcal);
					hil = mid-1;
				}
			}
			answer = min(answer,ta);
		}
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}else{
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}
			}
			answer = min(answer,ta);
		}
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}else{
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}
			}
			answer = min(answer,ta);
		}

	cout<<answer<<"\n";

}

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		test();
	}
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second

using namespace std;

pair<ll,ll> fun(ll x,ll h[],ll n){
	ll r=0,a=0;
	f(i,n){
		if(h[i]>x)
			r=r+(h[i]-x);
		else
			a = a + (x-h[i]);
	}
	return {a,r};
}

void test(){
	ll n,a,r,m;
	cin>>n>>a>>r>>m;
	ll h[n];
	f(i,n)cin>>h[i];
	ll high = 0,low = INT_MAX;
	f(i,n){
		high = max(high,h[i]);
		low = min(low,h[i]);
	}

	// case first move is efficient
	pair<ll,ll> qq = fun(low,h,n);
	ll answer  = qq.F*a + qq.S*r;
	qq = fun(high,h,n);
	answer = min(answer,qq.F*a + qq.S*r);

	{
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = m*pp.F + (pp.S-pp.F)*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}else{
					ll tcal = m*pp.S + (pp.F-pp.S)*a;
					ta = min(ta,tcal);
					hil = mid-1;
				}
			}
			answer = min(answer,ta);
		}

		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = m*pp.F + (pp.S-pp.F)*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}else{
					ll tcal = m*pp.S + (pp.F-pp.S)*a;
					ta = min(ta,tcal);
					lol = mid+1;
				}
			}
			answer = min(ta,answer); //ta;
		}
	}

	{
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}else{
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}
			}
			answer = min(answer,ta); //ta;
		}
		//
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}else{
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}
			}
			answer = min(answer,ta);
		}
	}
	{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = m*pp.F + (pp.S-pp.F)*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}else{
					ll tcal = m*pp.S + (pp.F-pp.S)*a;
					ta = min(ta,tcal);
					lol = mid+1;
				}
			}
			answer = min(answer,ta);
		}
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = m*pp.F + (pp.S-pp.F)*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}else{
					ll tcal = m*pp.S + (pp.F-pp.S)*a;
					ta = min(ta,tcal);
					hil = mid-1;
				}
			}
			answer = min(answer,ta);
		}
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}else{
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}
			}
			answer = min(answer,ta);
		}
		{
			ll hil = high,lol = low;
			ll ta = (n*high*a);
			while(lol<=hil){
				ll mid = lol + (hil-lol)/2;

				pair<ll,ll> pp = fun(mid,h,n);

				if(pp.F<=pp.S){
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					lol = mid+1;
				}else{
					ll tcal = pp.F*a + pp.S*r;
					ta = min(ta,tcal);
					hil = mid-1;
				}
			}
			answer = min(answer,ta);
		}

	cout<<answer<<"\n";

}

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		test();
	}
}


#include<bits/stdc++.h>
#define ll long long
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;

ll a,r,m;
ll fun(int ht,int h[],int n){
	ll add = 0, rem = 0;
	f(i,n){
		if(h[i]>ht)rem+=h[i]-ht;
		else add+=ht-h[i];
	}
	if(m<a+r){
		ll val = min(add,rem)*m;
		if(add>rem)
  		    val+=a*(add-rem);
            else
                val+=r*(rem-add);
            return val;
	}else{
		ll val = a*add + r*rem;
		return val;
	}
}

void test(){
	int n;
	scanf("%d %d %d %d",&n,&a,&r,&m);
	int h[n];
	f(i,n)scanf("%d",&h[i]);

	int low = 1e9+1, high = 0;
	f(i,n)low = min(h[i],low), high = max(high,h[i]);

	ll answer = min(fun(low,h,n),fun(high,h,n));

	int ans = low;
	while(high-low>3){
		int m1 = low + (high-low)/3;
		int m2 = high - (high-low)/3;
		ll val1 = fun(m1,h,n);
		ll val2 = fun(m2,h,n);

		if(val1<val2)low = m1;
		else high = m2;
	}
	answer = min(answer,fun(low,h,n));
	for(int i=low;i<=high;i++){
		answer = min(answer,fun(i,h,n));
	}
	cout<<answer<<"\n";
}

int main(){
//	std::ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		test();
	}
}


#include<bits/stdc++.h>
#define ll long long
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;

ll a,r,m;
ll fun(int ht,int h[],int n){
	ll add = 0, rem = 0;
	f(i,n){
		if(h[i]>ht)rem+=h[i]-ht;
		else add+=ht-h[i];
	}
	if(m<a+r){
		ll val = min(add,rem)*m;
		if(add>rem)
  		    val+=a*(add-rem);
            else
                val+=r*(rem-add);
            return val;
	}else{
		ll val = a*add + r*rem;
		return val;
	}
}

void test(){
	int n;
	scanf("%d %d %d %d",&n,&a,&r,&m);
	int h[n];
	f(i,n)scanf("%d",&h[i]);

	int low = 1e9+1, high = 0;
	f(i,n)low = min(h[i],low), high = max(high,h[i]);

	ll answer = min(fun(low,h,n),fun(high,h,n));

	int ans = low;
	while(high-low>3){
		int m1 = low + (high-low)/3;
		int m2 = high - (high-low)/3;
		ll val1 = fun(m1,h,n);
		ll val2 = fun(m2,h,n);

		if(val1>val2)low = m1;
		else high = m2;
	}
	answer = min(answer,fun(low,h,n));
	for(int i=low;i<=high;i++){
		answer = min(answer,fun(i,h,n));
	}
	cout<<answer<<"\n";
}

int main(){
//	std::ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		test();
	}
}


/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;

ll n,a,r,m,h[N],sum[N];
ll check(int X){
    ll u=0,d=0;
    rep(i,1,n){
        if(h[i]>X) u+=h[i]-X;
        if(h[i]<X) d+=X-h[i];
    }
    ll y=min(u,d);
    u-=y,d-=y;
    ll ans=y*m+u*r+d*a;
    return ans;
}
signed main(){
    FastIO;
    cin>>n>>a>>r>>m;
    m=min(m,a+r);
    rep(i,1,n) cin>>h[i];
    sort(h+1,h+n+1);
    rep(i,1,n) sum[i]=sum[i-1]+h[i];
    int L=0,R=1e9;
    while(R-L>4){
        int mid=(L+R)/2;
        if(check(mid)>check(mid+1)) L=mid;
        else R=mid+1;
    }
    ll ans=1e18;
    rep(i,L,R) ans=min(ans,check(i));
    cout<<ans;
    return 0;
}


/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;

ll n,a,r,m,h[N],sum[N];
ll check(int X){
    ll u=0,d=0;
    rep(i,1,n){
        if(h[i]>X) u+=h[i]-X;
        if(h[i]<X) d+=X-h[i];
    }
    ll y=min(u,d);
    u-=y,d-=y;
    ll ans=y*m+u*r+d*a;
    return ans;
}
signed main(){
    FastIO;
    cin>>n>>a>>r>>m;
    m=min(m,a+r);
    rep(i,1,n) cin>>h[i];
    sort(h+1,h+n+1);
    rep(i,1,n) sum[i]=sum[i-1]+h[i];
    int L=0,R=1e9;
    while(R-L>3){
        int mid=(L+R)/2;
        if(check(mid)>check(mid+1)) L=mid;
        else R=mid+1;
    }
    ll ans=1e18;
    rep(i,L,R) ans=min(ans,check(i));
    cout<<ans;
    return 0;
}


/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;

ll n,a,r,m,h[N],sum[N];
signed main(){
    FastIO;
    cin>>n>>a>>r>>m;
    rep(i,1,n) cin>>h[i];
    sort(h+1,h+n+1);
    rep(i,1,n) sum[i]=sum[i-1]+h[i];
    ll ans=1e18;
    rep(i,1,n){
        ll u=sum[n]-sum[i]-(n-i)*h[i],d=(i-1)*h[i]-sum[i-1];
        ll x=min(a+r,m);
        ll y=min(u,d);
        ll tans=y*x;
        u-=y,d-=y;
        tans+=u*r+d*a;
        ans=min(ans,tans);
    }
    for(ll X=sum[n]/n;X<=(sum[n]+n-1)/n;X++){
        int p=1,q=-1;
        rep(i,1,n){
            if(h[i]>=X and q==-1) q=i;
            if(h[i]<=X) p=i;
        }
        ll u=sum[n]-sum[q-1]-(n-q+1)*X,d=p*X-sum[p];
        ll x=min(a+r,m);
        ll y=min(u,d);
        ll tans=y*x;
        u-=y,d-=y;
        tans+=u*r+d*a;
        ans=min(ans,tans);
    }
    cout<<ans;
    return 0;
}


/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;

ll n,a,r,m,h[N],sum[N];
ll check(int X){
    ll u=0,d=0;
    rep(i,1,n){
        if(h[i]>X) u+=h[i]-X;
        if(h[i]<X) d+=X-h[i];
    }
    ll y=min(u,d);
    u-=y,d-=y;
    ll ans=y*m+u*r+d*a;
    return ans;
}
signed main(){
    FastIO;
    cin>>n>>a>>r>>m;
    m=min(m,a+r);
    rep(i,1,n) cin>>h[i];
    sort(h+1,h+n+1);
    rep(i,1,n) sum[i]=sum[i-1]+h[i];
    int L=0,R=1e9;
    while(R-L>2){
        int mid=(L+R)/2;
        if(check(mid)>check(mid+1)) L=mid;
        else R=mid+1;
    }
    ll ans=1e18;
    rep(i,L,R) ans=min(ans,check(i));
    cout<<ans;
    return 0;
}


/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;

ll n,a,r,m,h[N];
ll check(int X){
    ll u=0,d=0;
    rep(i,1,n){
        if(h[i]>X) u+=h[i]-X;
        if(h[i]<X) d+=X-h[i];
    }
    ll y=min(u,d);
    u-=y,d-=y;
    ll ans=y*m+u*r+d*a;
    return ans;
}
signed main(){
    FastIO;
    cin>>n>>a>>r>>m;
    m=min(m,a+r);
    rep(i,1,n) cin>>h[i];
    sort(h+1,h+n+1);
    int L=0,R=1e9;
    while(R-L>3){
        int mid=(L+R)/2;
        if(check(mid)>check(mid+1)) L=mid;
        else R=mid+1;
    }
    ll ans=1e18;
    rep(i,L,R) ans=min(ans,check(i));
    cout<<ans;
    return 0;
}


// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

/* ------------------------------ TEMPLATE BEGIN ------------------------------ */

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,mmx,avx,avx2,fma,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

/* ----------------- ORDERED SET (POLICY BASED DS) ----------------- */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree
    <T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

/* -------------- BETTER RANDOM (RAND() IS DANGEROUS) -------------- */
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

/* ----------------- CUSTOM HASH FUNCTION FOR UMAP ----------------- */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(tuple<uint64_t,uint64_t,uint64_t> x) const {
        uint64_t a, b, c;
        tie(a,b,c) = x;
        static const uint64_t FIXED_RANDOM =
            chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(a+b*uint64_t(1e6)+c*uint64_t(1e12) + FIXED_RANDOM);
    }
};

/* ----------------------- DEBUGGING UTILITY ----------------------- */
#define cerr cout
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {
    cerr << t; if(sizeof...(v)) cerr << ", "; _print(v...);
}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for (ll i = (ll)(x); i < (ll)(n); i++)
#define rrep(i, x, n) for (ll i = (ll)(x); i >= (ll)(n); i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define bs binary_search
#define minSelf(a, b) a = min(a, b)
#define maxSelf(a, b) a = max(a, b)
#define mem(arr, x) memset(arr, x, sizeof(arr))
using ll = long long int;
using ld = long double;
template <typename T, typename V> using P = pair<T, V>;
template <typename T> using V = vector<T>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 0x3f3f3f3f; // ~1e9 (1061109567)
constexpr ld PI = 3.1415926535897932384626;
constexpr ld EPS = 1e-9;
#define endl '\n' // REMOVE FOR INTERACTIVE TASKS
constexpr ll MAX = 1e5+5;

/* ------------------------------- TEMPLATE END ------------------------------- */

int main() {
    ll n, a, r, m;
    scanf("%lld%lld%lld%lld", &n, &a, &r, &m);
    m = min(m, a+r);
    ll v[n], mx = 0;
    rep(i, 0, n) cin >> v[i], mx = max(mx,v[i]);
    auto solve = [&](ll h) {
        ll mor = 0, les = 0, ans = 0;
        rep(i, 0, n) mor += max(0ll,v[i]-h), les += max(0ll,h-v[i]);
        if(mor > les) ans = (mor-les)*r;
        else ans = (les-mor)*a;
        return ans+min(mor, les)*m;
    };
    ll lo = 0, hi = mx, ans = INF;
    while(lo <= hi) {
        ll mid = (lo+hi)/2;
        ll ans_1 = solve(mid), ans_2 = solve(mid+1);
        if(ans_1 < ans_2) ans = ans_1, hi = mid-1;
        else ans = ans_2, lo = mid+1;
    }
    printf("%lld", ans);
}


// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

/* ------------------------------ TEMPLATE BEGIN ------------------------------ */

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,mmx,avx,avx2,fma,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

/* ----------------- ORDERED SET (POLICY BASED DS) ----------------- */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree
    <T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

/* -------------- BETTER RANDOM (RAND() IS DANGEROUS) -------------- */
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

/* ----------------- CUSTOM HASH FUNCTION FOR UMAP ----------------- */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(tuple<uint64_t,uint64_t,uint64_t> x) const {
        uint64_t a, b, c;
        tie(a,b,c) = x;
        static const uint64_t FIXED_RANDOM =
            chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(a+b*uint64_t(1e6)+c*uint64_t(1e12) + FIXED_RANDOM);
    }
};

/* ----------------------- DEBUGGING UTILITY ----------------------- */
#define cerr cout
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {
    cerr << t; if(sizeof...(v)) cerr << ", "; _print(v...);
}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for (ll i = (ll)(x); i < (ll)(n); i++)
#define rrep(i, x, n) for (ll i = (ll)(x); i >= (ll)(n); i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define bs binary_search
#define minSelf(a, b) a = min(a, b)
#define maxSelf(a, b) a = max(a, b)
#define mem(arr, x) memset(arr, x, sizeof(arr))
using ll = long long int;
using ld = long double;
template <typename T, typename V> using P = pair<T, V>;
template <typename T> using V = vector<T>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 0x3f3f3f3f; // ~1e9 (1061109567)
constexpr ld PI = 3.1415926535897932384626;
constexpr ld EPS = 1e-9;
#define endl '\n' // REMOVE FOR INTERACTIVE TASKS
constexpr ll MAX = 1e5+5;

/* ------------------------------- TEMPLATE END ------------------------------- */

int main() {
    ll n, a, r, m;
    scanf("%lld%lld%lld%lld", &n, &a, &r, &m);
    m = min(m, a+r);
    ll v[n], mx = 0;
    rep(i, 0, n) cin >> v[i], mx = max(mx,v[i]);
    auto solve = [&](ll h) {
        ll mor = 0, les = 0, ans = 0;
        rep(i, 0, n) mor += max(0ll,v[i]-h), les += max(0ll,h-v[i]);
        if(mor > les) ans = (mor-les)*r;
        else ans = (les-mor)*a;
        return ans+min(mor, les)*m;
    };
    ll lo = 0, hi = mx, ans = INF;
    while(lo <= hi) {
        ll mid = (lo+hi)/2;
        ll ans_1 = solve(mid), ans_2 = solve(mid+1);
        if(ans_1 < ans_2) ans = ans_1, hi = mid-1;
        else ans = ans_2, lo = mid+1;
    }
    printf("%lld", ans);
}