#include<bits/stdc++.h>
#include<fstream>
#include <chrono>
#define ll                    long long int
#define loop(i ,a,b)           for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)          for(int i=(int)a;i<=(int)b;++i)
#define loopl(i,a,b)          for(ll i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define count_1(n)            __builtin_popcountll(n)
#define pb                    push_back
#define eb                    emplace_back
#define ab(a)                 (a<0)?(-1*a):a
#define pc                    putchar_unlocked
#define gc                    getchar_unlocked
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define MAX1                   1e9
#define MIN                   -1e9
#define itoc(c)               ((char)(((int)'0')+c))
#define vi                    vector<int>
#define vvi                   vector<vi>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define max(x,y)              (x>y)?x:y
#define min(x,y)              (x<y)?x:y
#define mid(s,e)              (s+(e-s)/2)
#define mini                  INT_MIN
#define ifc(i)                (flag[i>>6]&(1<<((i>>1)&31)))
#define isc(i)                (flag[i>>6]|=(1<<((i>>1)&31)))
#define chk(n)                (n==2||(n>2&&(n&1)&&!ifc(n)))
#define sv()                  int t; scanf("%d",&t); while(t--)
using namespace std;
using namespace std::chrono;
#define MAX   1e16;
ll n,a,b,m;

int ch(ll ar[], int k)
{
    ll an1 =0, an2 =0;
    for(int i =0;i<n;i++)
    {
       if(ar[i] < k)
        an1 += k - ar[i];
      else if(ar[i] > k)
        an2 += ar[i] - k;
    }
    ll val1 = an1*a + an2*b;
    ll val2 = 0;
    if(an1 >  an2){
      val2 = m*an2;
      val2 += a*(an1 - an2);
    }
    else
    {
      val2 += m*an1;
      val2 += b*(an2 - an1);
    }
    return min(val1, val2);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin>>n>>a>>b>>m;
  ll ar[n];
  if(m > a+b)
    m = a+b;
  for(int i =0;i<n;i++)
    cin>>ar[i];
  ll ma = 1e9;
  ll mi = 0;
  ll ans =mi;
  while(ma >= mi)
    {
        int mid = mi + (ma - mi)/2;
        ll val1 = ch(ar, mid-1);
        ll val2 = ch(ar, mid);
        ll val3 = ch(ar, mid+1);
        //cout<<val1<<" "<<val2<<" "<<val3<<"\n";
        if(ma == mi)
        {
           ans = val2;
           break;
        }
        ans = val2;
        if(val1 <= val2 && val2 < val3)
        {
            ma = mid-1;
        }
        else if(val1 >  val2 && val2 >= val3)
        {
           mi  = mid+1;
        }
        else
          break;

    }
    cout<<ans<<"\n";

}


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

typedef long long ll;
typedef long double ld;

ll a[100005];
ll b[100005];
ll sum;
ll ans = LLONG_MAX;
int n,x,y,z;

ll check(ll X){
    ll cur = 0;
    for(int i=0;i<n;i++){
        if(a[i]<X){
            cur += (X-a[i])*x;
        }
        else if(a[i]>X){
            cur += (a[i]-X)*y;
        }
    }
    return cur;
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> x >> y >> z;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a,a+n);
    // swap + balance
    ll swaps = 0;
    int h = sum/n;
    if(sum%n==0){
        for(int i=0;i<n;i++){
            if(a[i]!=sum/n)swaps+=abs(h-a[i]);
        }
        swaps /= 2;
        ans = swaps * z;
    }
    else{
        ll sub = sum%n;
        ll add = n-(sum%n);
        ll t = add;
        // try adding
        for(int i=0;i<n;i++){
            b[i]=a[i];
        }
        for(int i=0;i<n;i++){
            if(b[i]<h+1){
                int to_add = min(h+1-b[i],t);
                b[i] += to_add;
                t -= to_add;
            }
        }
        for(int i=0;i<n;i++){
            if(b[i]!=h+1)swaps+=(abs(b[i]-(h+1)));
        }
        swaps/=2;
        ans = min(ans,swaps*z+add*x);
        // try subtracting
        t = sub;
        swaps = 0;
        for(int i=0;i<n;i++){
            b[i]=a[i];
        }
        for(int i=0;i<n;i++){
            if(b[i]>h){
                int to_sub = min(h+1-b[i],t);
                b[i] -= to_sub;
                t -= to_sub;
            }
        }
        for(int i=0;i<n;i++){
            if(b[i]!=h+1)swaps+=(abs(b[i]-h+1));
        }
        swaps/=2;
        ans = min(ans,swaps*z+sub*y);
    }
    // ternary search to see how much add and how much to sub
    ll l = a[0];
    ll r = a[n-1];
    while(r-l>10){
        ll mid1 = (l+r)/3;
        ll mid2 = (l+r)/3*2;
        if( check(mid1) < check(mid2) ){
            r = mid2-1;
        }
        else if(check(mid1) > check(mid2)){
            l = mid1+1;
        }
        else{
            l = mid1;
            r = mid2;
        }
    }
    for(ll i=l;i<=r;i++){
        ans = min(ans,check(i));
    }
    cout << ans;

    return 0;
}


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

typedef long long ll;
typedef long double ld;

ll a[100005];
ll b[100005];
ll sum;
ll ans = LLONG_MAX;
int n,x,y,z;

ll check(ll X){
    ll cur = 0;
    for(int i=0;i<n;i++){
        if(a[i]<X){
            cur += (X-a[i])*x;
        }
        else if(a[i]>X){
            cur += (a[i]-X)*y;
        }
    }
    return cur;
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> x >> y >> z;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a,a+n);
    // swap + balance
    ll swaps = 0;
    int h = sum/n;
    if(sum%n==0){
        for(int i=0;i<n;i++){
            if(a[i]!=sum/n)swaps+=abs(h-a[i]);
        }
        swaps /= 2;
        ans = swaps * z;
    }
    else{
        ll sub = sum%n;
        ll add = n-(sum%n);
        ll t = add;
        // try adding
        for(int i=0;i<n;i++){
            b[i]=a[i];
        }
        for(int i=0;i<n;i++){
            if(b[i]<h+1){
                int to_add = min(h+1-b[i],t);
                b[i] += to_add;
                t -= to_add;
            }
        }
        for(int i=0;i<n;i++){
            if(b[i]!=h+1)swaps+=(abs(b[i]-h+1));
        }
        swaps/=2;
        ans = min(ans,swaps*z+add*x);
        swaps = 0;
        for(int i=0;i<n;i++){
            b[i]=a[i];
        }
        for(int i=0;i<n;i++){
            if(b[i]>h){
                int to_sub = min(h+1-b[i],t);
                b[i] -= to_sub;
                t -= to_sub;
            }
        }
        for(int i=0;i<n;i++){
            if(b[i]!=h+1)swaps+=(abs(b[i]-h+1));
        }
        swaps/=2;
        ans = min(ans,swaps*z+sub*y);
    }
    // ternary search to see how much add and how much to sub
    ll l = a[0];
    ll r = a[n-1];
    while(r-l>10){
        ll mid1 = (l+r)/3;
        ll mid2 = (l+r)/3*2;
        if( check(mid1) < check(mid2) ){
            r = mid2-1;
        }
        else if(check(mid1) > check(mid2)){
            l = mid1+1;
        }
        else{
            l = mid1;
            r = mid2;
        }
    }
    for(ll i=l;i<=r;i++){
        ans = min(ans,check(i));
    }
    cout << ans;

    return 0;
}


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

typedef long long ll;
typedef long double ld;

ll a[100005];
ll b[100005];
ll sum;
ll ans = LLONG_MAX;
int n,x,y,z;

ll check(ll X){
    ll cur = 0;
    for(int i=0;i<n;i++){
        if(a[i]<X){
            cur += (X-a[i])*x;
        }
        else if(a[i]>X){
            cur += (a[i]-X)*y;
        }
    }
    return cur;
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> x >> y >> z;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a,a+n);
    // swap + balance
    ll swaps = 0;
    int h = sum/n;
    if(sum%n==0){
        for(int i=0;i<n;i++){
            if(a[i]!=sum/n)swaps+=abs(h-a[i]);
        }
        swaps /= 2;
        ans = swaps * z;
    }
    else{
        ll sub = sum%n;
        ll add = n-(sum%n);
        ll t = add;
        // try adding
        for(int i=0;i<n;i++){
            b[i]=a[i];
        }
        for(int i=0;i<n;i++){
            if(b[i]<h+1){
                int to_add = min(h+1-b[i],t);
                b[i] += to_add;
                t -= to_add;
            }
        }
        for(int i=0;i<n;i++){
            if(b[i]!=h+1)swaps+=(abs(b[i]-(h+1)));
        }
        swaps/=2;
        ans = min(ans,swaps*z+add*x);
        // try subtracting
        t = sub;
        swaps = 0;
        for(int i=0;i<n;i++){
            b[i]=a[i];
        }
        for(int i=0;i<n;i++){
            if(b[i]>h){
                int to_sub = min(b[i]-h,t);
                b[i] -= to_sub;
                t -= to_sub;
            }
        }
        for(int i=0;i<n;i++){
            if(b[i]!=h)swaps+=(abs(b[i]-(h)));
        }
        swaps/=2;
        ans = min(ans,swaps*z+sub*y);
    }
    // ternary search to see how much add and how much to sub
    ll l = a[0];
    ll r = a[n-1];
    while(r-l>10){
        ll mid1 = (l+r)/3;
        ll mid2 = (l+r)/3*2;
        if( check(mid1) < check(mid2) ){
            r = mid2-1;
        }
        else if(check(mid1) > check(mid2)){
            l = mid1+1;
        }
        else{
            l = mid1;
            r = mid2;
        }
    }
    for(ll i=l;i<=r;i++){
        ans = min(ans,check(i));
    }
    cout << ans;

    return 0;
}


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

typedef long long ll;
typedef long double ld;

ll a[100005];
ll b[100005];
ll sum;
ll ans = LLONG_MAX;
ll n,x,y,z;

ll check(ll X){
    ll cur = 0;
    for(ll i=0;i<n;i++){
        if(a[i]<X){
            cur += (X-a[i])*x;
        }
        else if(a[i]>X){
            cur += (a[i]-X)*y;
        }
    }
    return cur;
}

int main()
{
    //ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> x >> y >> z;
    for(ll i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a,a+n);
    // swap + balance
    ll swaps = 0;
    ll h = sum/n;
    if(sum%n==0){
        for(ll i=0;i<n;i++){
            if(a[i]!=sum/n)swaps+=abs(h-a[i]);
        }
        swaps /= 2;
        ans = swaps * z;
    }
    else{
        ll sub = sum%n;
        ll add = n-(sum%n);
        ll t = add;
        // try adding
        for(ll i=0;i<n;i++){
            b[i]=a[i];
        }
        for(ll i=0;i<n;i++){
            if(b[i]<h+1){
                ll to_add = min(h+1-b[i],t);
                b[i] += to_add;
                t -= to_add;
            }
        }
        for(ll i=0;i<n;i++){
            if(b[i]!=h+1)swaps+=(abs(b[i]-(h+1)));
        }
        swaps/=2;
        ans = min(ans,swaps*z+add*x);
        // try subtracting
        t = sub;
        swaps = 0;
        for(ll i=0;i<n;i++){
            b[i]=a[i];
        }
        for(ll i=0;i<n;i++){
            if(b[i]>h){
                ll to_sub = min(b[i]-h,t);
                b[i] -= to_sub;
                t -= to_sub;
            }
        }
        for(ll i=0;i<n;i++){
            if(b[i]!=h)swaps+=(abs(b[i]-(h)));
        }
        swaps/=2;
        ans = min(ans,swaps*z+sub*y);
    }
    // ternary search to see how much add and how much to sub
    ll l = a[0];
    ll r = a[n-1];
    while(r-l>20){
        ll mid1 = l + (r - l) / 3;
        ll mid2 = r - (r - l) / 3;
        if( check(mid1) < check(mid2) ){
            r = mid2-1ll;
        }
        else if(check(mid1) > check(mid2)){
            l = mid1+1ll;
        }
        else{
            l = mid1;
            r = mid2;
        }
    }
    for(ll i=l;i<=r;i++){
        ans = min(ans,check(i));
    }
    cout << ans;

    return 0;
}


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

typedef long long ll;
typedef long double ld;

int n,a,r,m;
ll tot;
int h[100005];
int hh[100005];
ll f(ll x){
    for(int i=0;i<n;i++)hh[i]=h[i];
    ll cur = 0;
    ll dif = tot - x*n;
    ll t = abs(dif);
    // we need to subtract
    if(dif>=0){
        cur += r*t;
        for(int i=0;i<n;i++){
            if(hh[i]>x){
                ll to_sub = min(t,hh[i]-x);
                t -= to_sub;
                hh[i] -= to_sub;
            }
        }
        ll swaps = 0;
        for(int i=0;i<n;i++){
            swaps += abs(hh[i]-x);
        }
        swaps /= 2;
        cur += swaps * m;

    }
    else{
        // we need to add
        cur += a*t;
        for(int i=0;i<n;i++){
            if(hh[i]<x){
                ll to_add = min(t,x-hh[i]);
                t -= to_add;
                hh[i] += to_add;
            }
        }
        ll swaps = 0;
        for(int i=0;i<n;i++){
            swaps += abs(hh[i]-x);
        }
        swaps /= 2;
        cur += swaps * m;
    }
    return cur;
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> a >> r >> m;
    for(int i=0;i<n;i++){
        cin >> h[i];
        tot += h[i];
    }
    m = min(m,a+r);
    sort(h,h+n);
    ll l = h[0];
    ll r = h[n-1];
    while(r-l>10){
        ll mid1 = l + (r - l) / 3;
        ll mid2 = r - (r - l) / 3;
        ll x = f(mid1);
        ll y = f(mid2);
        if( x > y ){
            l = mid1 + 1;
        }
        else if(x < y){
            r = mid2 - 1;
        }
        else{
            l = mid1;
            r = mid2;
        }
    }
    ll ans = LLONG_MAX;
    for(int i=l;i<=r;i++){
        ans = min(ans,f(i));
    }
    cout << ans;
    return 0;
}


//********************************************************************//
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fi first
#define se second
#define RANGE(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define DFOR(i, a, b) for(int i = a; i > b; --i)
#define DEB(x) cout << #x << ": " << x << endl
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define DISPV(v) { for(auto x___: v) cout << x___ << " "; cout << endl; }
#define DISPM(m) { for(auto x____: m){ cout << x____.first << ": " << x____.second << endl; } };
#define DISPMV(m) { for(auto x_____: m){ cout << x_____.first << ": " ;DISPV(x_____.second);} };
using LL = long long;
using VI = vector <int>;
using VC = vector <char>;
using VS = vector <string>;
using VL = vector <long long>;
using VVI = vector<VI>;
using VVL = vector <VL>;
using MII = map<int, int>;
using MIVI = map<int, VI>;
using MSS = map<string, string>;
using MLL = map<LL, LL>;
int READ_INT(){int temp;cin>>temp;return temp;}      // read an int
LL READ_LONG(){LL temp;cin>>temp;return temp;}      // read a long long
void mcs(VI &series, int &max_sum){                    // maximum contigous sub sum(kadane)
    int s=0;
    for(auto x: series){
        s += x;
        max_sum = max(max_sum, s);
        if(s < 0)s = 0;
    }
}
template<typename T>
T MAX(T t){ return t;}
template <typename T, typename... Args>
T MAX(T t, Args... args){ return max(t, MAX(args...)); }
const int MOD = int(1e9) + 7;
const int INF = 1e9 + 5;
const double PI = acos(-1.0); //M_PI;
const double EPS = 1e-9;
//********************************************************************//

LL n, a, r, m;
VL heights;

LL find_cost(LL x){
    LL inc = 0, dec = 0;
    for(auto h: heights){
        if(h >= x)dec += (h-x);
        else inc += (x-h);
    }
    if(inc == 0 || dec == 0)return a*inc + r*dec;
    if(a+r <= m)return a*inc + r*dec;

    if(inc >= dec)
        return m * dec + (inc - dec)*a;
    else
        return m * inc + (dec - inc)*r;
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n >> a >> r >> m;
    RANGE(i,n)heights.push_back(READ_LONG());

    LL ans = 1e15;
    LL right = 1e18, left = 0, m1 = 0, m2 = 0;
    // cout << right << endl;
    while(right - left > 2){
        m1 = left + (right - left)/3;
        m2 = right - (right - left)/3;
        LL cost_m1 = find_cost(m1), cost_m2 = find_cost(m2);
        if(cost_m1 < cost_m2)right = m2;
        else if(cost_m1 > cost_m2)left = m1;
        else{
            left = m1;
            right = m2;
        }
        ans = min(ans, min(cost_m2, cost_m1));
    }
    // cout << left << ", " << m1 << ", " << m2 << ", " << right << endl;
    cout << ans << endl;
    return 0;
}

/* complie flags
-Wall -Wextra -pedantic -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector
*/


//********************************************************************//
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fi first
#define se second
#define RANGE(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define DFOR(i, a, b) for(int i = a; i > b; --i)
#define DEB(x) cout << #x << ": " << x << endl
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define DISPV(v) { for(auto x___: v) cout << x___ << " "; cout << endl; }
#define DISPM(m) { for(auto x____: m){ cout << x____.first << ": " << x____.second << endl; } };
#define DISPMV(m) { for(auto x_____: m){ cout << x_____.first << ": " ;DISPV(x_____.second);} };
using LL = long long;
using VI = vector <int>;
using VC = vector <char>;
using VS = vector <string>;
using VL = vector <long long>;
using VVI = vector<VI>;
using VVL = vector <VL>;
using MII = map<int, int>;
using MIVI = map<int, VI>;
using MSS = map<string, string>;
using MLL = map<LL, LL>;
int READ_INT(){int temp;cin>>temp;return temp;}      // read an int
LL READ_LONG(){LL temp;cin>>temp;return temp;}      // read a long long
void mcs(VI &series, int &max_sum){                    // maximum contigous sub sum(kadane)
    int s=0;
    for(auto x: series){
        s += x;
        max_sum = max(max_sum, s);
        if(s < 0)s = 0;
    }
}
template<typename T>
T MAX(T t){ return t;}
template <typename T, typename... Args>
T MAX(T t, Args... args){ return max(t, MAX(args...)); }
const int MOD = int(1e9) + 7;
const int INF = 1e9 + 5;
const double PI = acos(-1.0); //M_PI;
const double EPS = 1e-9;
//********************************************************************//

LL n, a, r, m;
VL heights;

LL find_cost(LL x){
    LL inc = 0, dec = 0;
    for(auto h: heights){
        if(h >= x)dec += (h-x);
        else inc += (x-h);
    }
    if(inc == 0 || dec == 0)return a*inc + r*dec;
    if(a+r <= m)return a*inc + r*dec;

    if(inc >= dec)
        return m * dec + (inc - dec)*a;
    else
        return m * inc + (dec - inc)*r;
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n >> a >> r >> m;
    RANGE(i,n)heights.push_back(READ_LONG());

    LL ans = 1e15;
    LL right = 1e18, left = 0, m1 = 0, m2 = 0;
    cout << right << endl;
    while(right - left > 2){
        m1 = left + (right - left)/3;
        m2 = right - (right - left)/3;
        LL cost_m1 = find_cost(m1), cost_m2 = find_cost(m2);
        if(cost_m1 < cost_m2)right = m2;
        else if(cost_m1 > cost_m2)left = m1;
        else{
            left = m1;
            right = m2;
        }
        ans = min(ans, min(cost_m2, cost_m1));
    }
    // cout << left << ", " << m1 << ", " << m2 << ", " << right << endl;
    cout << ans << endl;
    return 0;
}

/* complie flags
-Wall -Wextra -pedantic -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector
*/


//********************************************************************//
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fi first
#define se second
#define RANGE(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define DFOR(i, a, b) for(int i = a; i > b; --i)
#define DEB(x) cout << #x << ": " << x << endl
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define DISPV(v) { for(auto x___: v) cout << x___ << " "; cout << endl; }
#define DISPM(m) { for(auto x____: m){ cout << x____.first << ": " << x____.second << endl; } };
#define DISPMV(m) { for(auto x_____: m){ cout << x_____.first << ": " ;DISPV(x_____.second);} };
using LL = long long;
using VI = vector <int>;
using VC = vector <char>;
using VS = vector <string>;
using VL = vector <long long>;
using VVI = vector<VI>;
using VVL = vector <VL>;
using MII = map<int, int>;
using MIVI = map<int, VI>;
using MSS = map<string, string>;
using MLL = map<LL, LL>;
int READ_INT(){int temp;cin>>temp;return temp;}      // read an int
LL READ_LONG(){LL temp;cin>>temp;return temp;}      // read a long long
void mcs(VI &series, int &max_sum){                    // maximum contigous sub sum(kadane)
    int s=0;
    for(auto x: series){
        s += x;
        max_sum = max(max_sum, s);
        if(s < 0)s = 0;
    }
}
template<typename T>
T MAX(T t){ return t;}
template <typename T, typename... Args>
T MAX(T t, Args... args){ return max(t, MAX(args...)); }
const int MOD = int(1e9) + 7;
const int INF = 1e9 + 5;
const double PI = acos(-1.0); //M_PI;
const double EPS = 1e-9;
//********************************************************************//

LL n, a, r, m;
VL heights;

LL find_cost(LL x){
    LL inc = 0, dec = 0;
    for(auto h: heights){
        if(h >= x)dec += (h-x);
        else inc += (x-h);
    }
    if(inc * dec == 0)return a*inc + r*dec;
    if(a+r <= m)return a*inc + r*dec;

    if(inc >= dec)
        return m * dec + (inc - dec)*a;
    else
        return m * inc + (dec - inc)*r;
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n >> a >> r >> m;
    RANGE(i,n)heights.push_back(READ_LONG());

    LL ans = LLONG_MAX;
    LL right = 1e9+1, left = 0, m1 = 0, m2 = 0;
    // cout << right << endl;
    while(right - left > 2){
        m1 = left + (right - left)/3;
        m2 = right - (right - left)/3;
        // cout << left << ", " << m1 << ", " << m2 << ", " << right << endl;
        LL cost_m1 = find_cost(m1), cost_m2 = find_cost(m2);
        if(cost_m1 < cost_m2)right = m2;
        else if(cost_m1 > cost_m2)left = m1;
        else{
            left = m1;
            right = m2;
        }
        ans = min(ans, min(cost_m2, cost_m1));
    }
    cout << ans << endl;
    // cout << LLONG_MAX << endl;
    return 0;
}

/* complie flags
-Wall -Wextra -pedantic -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector
*/


//********************************************************************//
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fi first
#define se second
#define RANGE(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define DFOR(i, a, b) for(int i = a; i > b; --i)
#define DEB(x) cout << #x << ": " << x << endl
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define DISPV(v) { for(auto x___: v) cout << x___ << " "; cout << endl; }
#define DISPM(m) { for(auto x____: m){ cout << x____.first << ": " << x____.second << endl; } };
#define DISPMV(m) { for(auto x_____: m){ cout << x_____.first << ": " ;DISPV(x_____.second);} };
using LL = long long;
using VI = vector <int>;
using VC = vector <char>;
using VS = vector <string>;
using VL = vector <long long>;
using VVI = vector<VI>;
using VVL = vector <VL>;
using MII = map<int, int>;
using MIVI = map<int, VI>;
using MSS = map<string, string>;
using MLL = map<LL, LL>;
int READ_INT(){int temp;cin>>temp;return temp;}      // read an int
LL READ_LONG(){LL temp;cin>>temp;return temp;}      // read a long long
void mcs(VI &series, int &max_sum){                    // maximum contigous sub sum(kadane)
    int s=0;
    for(auto x: series){
        s += x;
        max_sum = max(max_sum, s);
        if(s < 0)s = 0;
    }
}
template<typename T>
T MAX(T t){ return t;}
template <typename T, typename... Args>
T MAX(T t, Args... args){ return max(t, MAX(args...)); }
const int MOD = int(1e9) + 7;
const int INF = 1e9 + 5;
const double PI = acos(-1.0); //M_PI;
const double EPS = 1e-9;
//********************************************************************//

LL n, a, r, m;
VL heights;

LL find_cost(LL x){
    LL inc = 0, dec = 0;
    for(auto h: heights){
        if(h >= x)dec += (h-x);
        else inc += (x-h);
    }
    if(inc == 0 || dec == 0)return a*inc + r*dec;
    if(a+r <= m)return a*inc + r*dec;

    if(inc >= dec)
        return m * dec + (inc - dec)*a;
    else
        return m * inc + (dec - inc)*r;
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n >> a >> r >> m;
    RANGE(i,n)heights.push_back(READ_LONG());

    LL ans = 1e15;
    LL right = 1e9+1, left = 0, m1 = 0, m2 = 0;
    while(right - left > 2){
        m1 = left + (right - left)/3;
        m2 = right - (right - left)/3;
        LL cost_m1 = find_cost(m1), cost_m2 = find_cost(m2);
        if(cost_m1 < cost_m2)right = m2;
        else if(cost_m1 > cost_m2)left = m1;
        else{
            left = m1;
            right = m2;
        }
        ans = min(ans, min(cost_m2, cost_m1));
    }
    // cout << left << ", " << m1 << ", " << m2 << ", " << right << endl;
    cout << ans << endl;
    return 0;
}

/* complie flags
-Wall -Wextra -pedantic -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector
*/


//********************************************************************//
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fi first
#define se second
#define RANGE(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define DFOR(i, a, b) for(int i = a; i > b; --i)
#define DEB(x) cout << #x << ": " << x << endl
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define DISPV(v) { for(auto x___: v) cout << x___ << " "; cout << endl; }
#define DISPM(m) { for(auto x____: m){ cout << x____.first << ": " << x____.second << endl; } };
#define DISPMV(m) { for(auto x_____: m){ cout << x_____.first << ": " ;DISPV(x_____.second);} };
using LL = long long;
using VI = vector <int>;
using VC = vector <char>;
using VS = vector <string>;
using VL = vector <long long>;
using VVI = vector<VI>;
using VVL = vector <VL>;
using MII = map<int, int>;
using MIVI = map<int, VI>;
using MSS = map<string, string>;
using MLL = map<LL, LL>;
int READ_INT(){int temp;cin>>temp;return temp;}      // read an int
LL READ_LONG(){LL temp;cin>>temp;return temp;}      // read a long long
void mcs(VI &series, int &max_sum){                    // maximum contigous sub sum(kadane)
    int s=0;
    for(auto x: series){
        s += x;
        max_sum = max(max_sum, s);
        if(s < 0)s = 0;
    }
}
template<typename T>
T MAX(T t){ return t;}
template <typename T, typename... Args>
T MAX(T t, Args... args){ return max(t, MAX(args...)); }
const int MOD = int(1e9) + 7;
const int INF = 1e9 + 5;
const double PI = acos(-1.0); //M_PI;
const double EPS = 1e-9;
//********************************************************************//

LL n, a, r, m;
VL heights;

LL find_cost(LL x){
    LL inc = 0, dec = 0;
    for(auto h: heights){
        if(h >= x)dec += (h-x);
        else inc += (x-h);
    }
    if(inc * dec == 0)return a*inc + r*dec;
    if(a+r <= m)return a*inc + r*dec;

    if(inc >= dec)
        return m * dec + (inc - dec)*a;
    else
        return m * inc + (dec - inc)*r;
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n >> a >> r >> m;
    RANGE(i,n)heights.push_back(READ_LONG());

    LL ans = 1e15;
    LL right = 1e9+1, left = 0, m1 = 0, m2 = 0;
    while(right - left > 2){
        m1 = left + (right - left)/3;
        m2 = right - (right - left)/3;
        LL cost_m1 = find_cost(m1), cost_m2 = find_cost(m2);
        if(cost_m1 < cost_m2)right = m2;
        else if(cost_m1 > cost_m2)left = m1;
        else{
            left = m1;
            right = m2;
        }
        ans = min(ans, min(cost_m2, cost_m1));
    }
    // cout << left << ", " << m1 << ", " << m2 << ", " << right << endl;
    cout << ans << endl;
    return 0;
}

/* complie flags
-Wall -Wextra -pedantic -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector
*/


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std::chrono;
ll n,a,r1,m,ans=0,val,sum;vector<ll> vec,pre;
ll check(ll mid)  {
  val=0;
  for(int i=0;i<n;i++)  {
    val+=max(0LL,vec[i]-mid);
  }
  // cout<<val<<endl;
  ll deficit=(mid*n)-(sum-val),cost=1e15;
  // cout<<deficit<<endl;
  if(deficit-val>=0)
    cost=min(val*r1+deficit*a,val*m+(deficit-val)*a);
  else
    cost=min(cost,deficit*m+(val-deficit)*r1);
  return cost;
}
int main()
{
  // input_from_file
  fastIO
  cin>>n>>a>>r1>>m;
  vec.resize(n,0);for(auto &x:vec)  {cin>>x;ans+=x*r1;sum+=x;}
  ll l=0,r=1e15,mid;bool flag=1;
  // cout<<ans<<endl;
  while(l<=r){
    mid=(l+r)/2;
    // if(flag)  {flag=0;mid=1;}else mid=(l+r)/2;
    ans=min(ans,check(mid));
    if(check(mid)<check(mid-1)) l=mid+1;
    else  r=mid-1;
    // cout<<"r="<<r<<" ,l="<<l<<" ,";
    // cout<<"mid="<<mid<<" ,ans="<<ans<<endl;
    // break;
  }
  cout<<ans;
  return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std::chrono;
ll n,a,r1,m,ans=0,val,sum;vector<ll> vec,pre;
ll check(ll mid)  {
  val=0;
  for(int i=0;i<n;i++)  {
    val+=max(0LL,vec[i]-mid);
  }
  // cout<<val<<endl;
  ll deficit=(mid*n)-(sum-val),cost=1e15;
  // cout<<deficit<<endl;
  if(deficit-val>=0)
    cost=min(val*r1+deficit*a,val*m+(deficit-val)*a);
  else
    cost=min(cost,deficit*m+(val-deficit)*r1);
  return cost;
}
int main()
{
  // input_from_file
  fastIO
  cin>>n>>a>>r1>>m;
  vec.resize(n,0);for(auto &x:vec)  {cin>>x;ans+=x*r1;sum+=x;}
  ll l=0,r=1e10,mid;bool flag=1;
  // cout<<ans<<endl;
  while(l<=r){
    mid=(l+r)/2;
    // if(flag)  {flag=0;mid=1;}else mid=(l+r)/2;
    ans=min(ans,check(mid));
    if(check(mid)<check(mid-1)) l=mid+1;
    else  r=mid-1;
    // cout<<"r="<<r<<" ,l="<<l<<" ,";
    // cout<<"mid="<<mid<<" ,ans="<<ans<<endl;
    // break;
  }
  cout<<ans;
  return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std::chrono;
ll n,a,r1,m,ans=0,val,sum;vector<ll> vec,pre;
ll check(ll mid)  {
  val=0;
  for(int i=0;i<n;i++)  {
    val+=max(0LL,vec[i]-mid);
  }
  ll deficit=(mid*n)-(sum-val),cost=1e18;
  if(deficit-val>=0)
    cost=min(val*r1+deficit*a,val*m+(deficit-val)*a);
  else
    cost=min(cost,deficit*m+(val-deficit)*r1);
  return cost;
}
int main()
{
  // input_from_file
  fastIO
  cin>>n>>a>>r1>>m;
  vec.resize(n,0);for(auto &x:vec)  {cin>>x;ans+=x*r1;sum+=x;}
  ll l=0,r=1e9,mid;bool flag=1;
  while(l<=r){
    mid=(l+r)/2;
    ans=min(ans,check(mid));
    if(check(mid)<check(mid-1)) l=mid+1;
    else  r=mid-1;
  }
  cout<<ans;
  return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std::chrono;
ll n,a,r1,m,ans=0,val,sum;vector<ll> vec,pre;
ll check(ll mid)  {
  val=0;
  for(int i=0;i<n;i++)  {
    val+=max(0LL,vec[i]-mid);
  }
  // cout<<val<<endl;
  ll deficit=(mid*n)-(sum-val),cost=1e15;
  // cout<<deficit<<endl;
  if(deficit-val>=0)
    cost=min(val*r1+deficit*a,val*m+(deficit-val)*a);
  else
    cost=min(cost,deficit*m+(val-deficit)*r1);
  return cost;
}
int main()
{
  // input_from_file
  fastIO
  cin>>n>>a>>r1>>m;
  vec.resize(n,0);for(auto &x:vec)  {cin>>x;ans+=x*r1;sum+=x;}
  ll l=0,r=100,mid;bool flag=1;
  // cout<<ans<<endl;
  while(l<=r){
    mid=(l+r)/2;
    // if(flag)  {flag=0;mid=1;}else mid=(l+r)/2;
    ans=min(ans,check(mid));
    if(check(mid)<check(mid-1)) l=mid+1;
    else  r=mid-1;
    // cout<<"r="<<r<<" ,l="<<l<<" ,";
    // cout<<"mid="<<mid<<" ,ans="<<ans<<endl;
    // break;
  }
  cout<<ans;
  return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std::chrono;
ll n,a,r1,m,ans=0,val,sum;vector<ll> vec,pre;
ll check(ll mid)  {
  val=0;
  for(int i=0;i<n;i++)  {
    val+=max(0LL,vec[i]-mid);
  }
  // cout<<val<<endl;
  ll deficit=(mid*n)-(sum-val),cost=1e18;
  // cout<<deficit<<endl;
  if(deficit-val>=0)
    cost=min(val*r1+deficit*a,val*m+(deficit-val)*a);
  else
    cost=min(cost,deficit*m+(val-deficit)*r1);
  return cost;
}
int main()
{
  // input_from_file
  fastIO
  cin>>n>>a>>r1>>m;
  vec.resize(n,0);for(auto &x:vec)  {cin>>x;ans+=x*r1;sum+=x;}
  ll l=0,r=1e9,mid;bool flag=1;
  // cout<<ans<<endl;
  while(l<=r){
    mid=(l+r)/2;
    // if(flag)  {flag=0;mid=1;}else mid=(l+r)/2;
    ans=min(ans,check(mid));
    if(check(mid)<check(mid-1)) l=mid+1;
    else  r=mid-1;
    // cout<<"r="<<r<<" ,l="<<l<<" ,";
    // cout<<"mid="<<mid<<" ,ans="<<ans<<endl;
    // break;
  }
  cout<<ans;
  return 0;

}


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

//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asort(s)        sort(s.begin(), s.end())
#define dsort(s)        sort(s.rbegin(), s.rend())
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)
#define all(s)          s.begin(), s.end()

const ll INF = LLONG_MAX;
const ll SZ = 1e5+5;
const ll mod = 1e9+7;

ll n, a, r, m, h[SZ], h1[SZ], cm[SZ];

ll upper(ll av) {
    ll st = 1, en = n, res, ps;
    while(st <= en) {
        ll mid = (st + en) / 2;
        if(h[mid] >= av) {
            ps = mid;
            en = mid - 1;
        }
        else st = mid + 1;
    }

    res = (cm[n] - cm[ps-1]) - ((n-ps+1)*av);
    return res;
}

ll lower(ll av) {
    ll st = 1, en = n, res, ps;
    while(st <= en) {
        ll mid = (st + en) / 2;
        if(h[mid] <= av) {
            ps = mid;
            st = mid + 1;
        }
        else en = mid - 1;
    }

    res = (ps * av) - cm[ps];
    return res;
}

ll solve(ll av) {
    ll c1 = lower(av);
    ll c2 = upper(av);
//    if(av == 3) cout << c1 << " " << c2 << "\n";

    ll op = min(c1, c2);
    if(m > (a+r)) op = 0;
//    ll op1 = op;

    ll t = op * m;
    t += ((c1-op) * a);
    t += ((c2-op) * r);
    return t;
}

int main() {
    FR;
    ll t = 0, x, y, z, i, j, k, g, p, q, ans = INF, sum = 0, c = 0;
    string s, s1, s2;

    cin >> n >> a >> r >> m;
    for1(i, n) cin >> h[i];

    sort(h+1, h+n+1);

    for1(i, n) cm[i] = cm[i-1] + h[i];

    if(m < (a+r)) {
        ans = 0;
        x = cm[n] / n;
        for1(i, n) h1[i] = x;
        c = cm[n]%n;
        for(i = n-c+1; i <= n; i++) h1[i]++;

        c = 0;
        for1(i, n) c += abs(h[i]-h1[i]);
        c /= 2;
        ans = (c * m);

        t = c = 0;
        for1(i, n) {
            if(h1[i] != h1[1]) t += r;
            if(h1[i] != h1[n]) c += a;
        }

        ans += min(t, c);
    }

    ll st = INF, en = -INF;
    for1(i, n) {
        st = min(st, h[i]);
        en = max(en, h[i]);
    }

    while(st <= en) {
        ll mid = (st + en) / 2;
        c = solve(mid);
        if(c < ans) {
            ans = c;
            en = mid - 1;
        }
        else st = mid + 1;
    }

    for1(i, n) {
        c = solve(h[i]);
//        printl(c);
        if(c < ans) ans = c;
    }

    cout << ans << "\n";

    return 0;
}


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

//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asort(s)        sort(s.begin(), s.end())
#define dsort(s)        sort(s.rbegin(), s.rend())
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)
#define all(s)          s.begin(), s.end()

const ll INF = LLONG_MAX;
const ll SZ = 1e5+5;
const ll mod = 1e9+7;

ll n, a, r, m, h[SZ], h1[SZ], cm[SZ];

ll upper(ll av) {
    ll st = 1, en = n, res, ps;
    while(st <= en) {
        ll mid = (st + en) / 2;
        if(h[mid] >= av) {
            ps = mid;
            en = mid - 1;
        }
        else st = mid + 1;
    }

    res = (cm[n] - cm[ps-1]) - ((n-ps+1)*av);
    return res;
}

ll lower(ll av) {
    ll st = 1, en = n, res, ps;
    while(st <= en) {
        ll mid = (st + en) / 2;
        if(h[mid] <= av) {
            ps = mid;
            st = mid + 1;
        }
        else en = mid - 1;
    }

    res = (ps * av) - cm[ps];
    return res;
}

ll solve(ll av) {
    ll c1 = lower(av);
    ll c2 = upper(av);
//    if(av == 3) cout << c1 << " " << c2 << "\n";

    ll op = min(c1, c2);
    if(m > (a+r)) op = 0;
//    ll op1 = op;

    ll t = op * m;
    t += ((c1-op) * a);
    t += ((c2-op) * r);
    return t;
}

int main() {
    FR;
    ll t = 0, x, y, z, i, j, k, g, p, q, ans = INF, sum = 0, c = 0;
    string s, s1, s2;

    cin >> n >> a >> r >> m;
    for1(i, n) cin >> h[i];

    sort(h+1, h+n+1);

    for1(i, n) cm[i] = cm[i-1] + h[i];

    if(m < (a+r)) {
        ans = 0;
        x = cm[n] / n;
        for1(i, n) h1[i] = x;
        c = cm[n]%n;
        for(i = n-c+1; i <= n; i++) h1[i]++;

        c = 0;
        for1(i, n) c += abs(h[i]-h1[i]);
        c /= 2;
        ans = (c * m);

        t = c = 0;
        for1(i, n) {
            if(h1[i] != h1[1]) t += r;
            if(h1[i] != h1[n]) c += a;
        }

        ans += min(t, c);
    }

//    ll st = 0, en = 1e9;

    for1(i, n) {
        c = solve(h[i]);
//        printl(c);
        if(c < ans) ans = c;
    }

    cout << ans << "\n";

    return 0;
}


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

//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asort(s)        sort(s.begin(), s.end())
#define dsort(s)        sort(s.rbegin(), s.rend())
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)
#define all(s)          s.begin(), s.end()

const ll INF = LLONG_MAX;
const ll SZ = 1e5+5;
const ll mod = 1e9+7;

ll n, a, r, m, h[SZ], h1[SZ], cm[SZ];

ll upper(ll av) {
    ll st = 1, en = n, res, ps;
    while(st <= en) {
        ll mid = (st + en) / 2;
        if(h[mid] >= av) {
            ps = mid;
            en = mid - 1;
        }
        else st = mid + 1;
    }

    res = (cm[n] - cm[ps-1]) - ((n-ps+1)*av);
    return res;
}

ll lower(ll av) {
    ll st = 1, en = n, res, ps;
    while(st <= en) {
        ll mid = (st + en) / 2;
        if(h[mid] <= av) {
            ps = mid;
            st = mid + 1;
        }
        else en = mid - 1;
    }

    res = (ps * av) - cm[ps];
    return res;
}

ll solve(ll av) {
    ll c1 = lower(av);
    ll c2 = upper(av);
//    if(av == 3) cout << c1 << " " << c2 << "\n";

    ll op = min(c1, c2);
    if(m > (a+r)) op = 0;
//    ll op1 = op;

    ll t = op * m;
    t += ((c1-op) * a);
    t += ((c2-op) * r);
    return t;
}

int main() {
    FR;
    ll t = 0, x, y, z, i, j, k, g, p, q, ans = INF, sum = 0, c = 0;
    string s, s1, s2;

    cin >> n >> a >> r >> m;
    for1(i, n) cin >> h[i];

    sort(h+1, h+n+1);

    for1(i, n) cm[i] = cm[i-1] + h[i];

    if(m < (a+r)) {
        ans = 0;
        x = cm[n] / n;
        for1(i, n) h1[i] = x;
        c = cm[n]%n;
        for(i = n-c+1; i <= n; i++) h1[i]++;

        c = 0;
        for1(i, n) c += abs(h[i]-h1[i]);
        if(c%2) ans = a;
        c /= 2;
        ans += (c * m);

        t = c = 0;
        for1(i, n) {
            if(h1[i] != h1[1]) t += r;
            if(h1[i] != h1[n]) c += a;
        }

        ans += min(t, c);
    }

//    ll st = 0, en = 1e9;

    for1(i, n) {
        c = solve(h[i]);
//        printl(c);
        if(c < ans) ans = c;
    }

    cout << ans << "\n";

    return 0;
}


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

//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asort(s)        sort(s.begin(), s.end())
#define dsort(s)        sort(s.rbegin(), s.rend())
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)
#define all(s)          s.begin(), s.end()

const ll INF = LLONG_MAX;
const ll SZ = 1e5+5;
const ll mod = 1e9+7;

ll n, a, r, m, h[SZ], h1[SZ], cm[SZ];

ll upper(ll av) {
    ll st = 1, en = n, res, ps;
    while(st <= en) {
        ll mid = (st + en) / 2;
        if(h[mid] >= av) {
            ps = mid;
            en = mid - 1;
        }
        else st = mid + 1;
    }

    res = (cm[n] - cm[ps-1]) - ((n-ps+1)*av);
    return res;
}

ll lower(ll av) {
    ll st = 1, en = n, res, ps;
    while(st <= en) {
        ll mid = (st + en) / 2;
        if(h[mid] <= av) {
            ps = mid;
            st = mid + 1;
        }
        else en = mid - 1;
    }

    res = (ps * av) - cm[ps];
    return res;
}

ll solve(ll av) {
    ll c1 = lower(av);
    ll c2 = upper(av);
//    if(av == 3) cout << c1 << " " << c2 << "\n";

    ll op = min(c1, c2);
    if(m > (a+r)) op = 0;
//    ll op1 = op;

    ll t = op * m;
    t += ((c1-op) * a);
    t += ((c2-op) * r);
    return t;
}

int main() {
    FR;
    ll t = 0, x, y, z, i, j, k, g, p, q, ans = INF, sum = 0, c = 0;
    string s, s1, s2;

    cin >> n >> a >> r >> m;
    for1(i, n) cin >> h[i];

    sort(h+1, h+n+1);

    for1(i, n) cm[i] = cm[i-1] + h[i];

    if(m < (a+r)) {
        ans = 0;
        x = cm[n] / n;
        for1(i, n) h1[i] = x;
        c = cm[n]%n;
        for(i = n-c+1; i <= n; i++) h1[i]++;

        c = 0;
        for1(i, n) c += abs(h[i]-h1[i]);
        if(c%2) ans = r;
        c /= 2;
        ans += (c * m);

        t = c = 0;
        for1(i, n) {
            if(h1[i] != h1[1]) t += r;
            if(h1[i] != h1[n]) c += a;
        }

        ans += min(t, c);
    }

//    ll st = 0, en = 1e9;

    for1(i, n) {
        c = solve(h[i]);
//        printl(c);
        if(c < ans) ans = c;
    }

    cout << ans << "\n";

    return 0;
}


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

//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asort(s)        sort(s.begin(), s.end())
#define dsort(s)        sort(s.rbegin(), s.rend())
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)
#define all(s)          s.begin(), s.end()

const ll INF = LLONG_MAX;
const ll SZ = 1e5+5;
const ll mod = 1e9+7;

ll n, a, r, m, h[SZ], cm[SZ];

ll upper(ll av) {
    ll st = 1, en = n, res = 0, ps = -1;
    while(st <= en) {
        ll mid = (st + en) / 2;
        if(h[mid] >= av) {
            ps = mid;
            en = mid - 1;
        }
        else st = mid + 1;
    }

    if(ps != -1) res = (cm[n] - cm[ps-1]) - ((n-ps+1)*av);
    return res;
}

ll lower(ll av) {
    ll st = 1, en = n, res = 0, ps = -1;
    while(st <= en) {
        ll mid = (st + en) / 2;
        if(h[mid] <= av) {
            ps = mid;
            st = mid + 1;
        }
        else en = mid - 1;
    }

    if(ps != -1) res = (ps * av) - cm[ps];
    return res;
}

ll solve(ll av) {
    ll c1 = lower(av);
    ll c2 = upper(av);

    ll op = min(c1, c2);

    ll t = op * m;
    t += ((c1-op) * a);
    t += ((c2-op) * r);

    return t;
}

int main() {
    FR;
    ll t = 0, x, y, z, i, j, k, g, p, q, ans = INF, sum = 0, c = 0;
    string s, s1, s2;

    cin >> n >> a >> r >> m;
    m = min(m, a+r);
    for1(i, n) cin >> h[i];

    sort(h+1, h+n+1);

    for1(i, n) cm[i] = cm[i-1] + h[i];

    ll st = 0, en = 1e9;

    while(st <= en) {
        ll mid1 = st + (en-st)/3;
        ll mid2 = en - (en-st)/3;

        ll c1 = solve(mid1);
        ll c2 = solve(mid2);

        if(c1 > c2) {
            ans = c2;
            st = mid1+1;
        }
        else {
            ans = c1;
            en = mid2-1;
        }
    }

    cout << ans << "\n";

    return 0;
}


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

//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asort(s)        sort(s.begin(), s.end())
#define dsort(s)        sort(s.rbegin(), s.rend())
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(auto itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)
#define all(s)          s.begin(), s.end()

const ll INF = LLONG_MAX;
const ll SZ = 1e5+5;
const ll mod = 1e9+7;

ll n, a, r, m, h[SZ], h1[SZ], cm[SZ];

ll upper(ll av) {
    ll st = 1, en = n, res, ps;
    while(st <= en) {
        ll mid = (st + en) / 2;
        if(h[mid] >= av) {
            ps = mid;
            en = mid - 1;
        }
        else st = mid + 1;
    }

    res = (cm[n] - cm[ps-1]) - ((n-ps+1)*av);
    return res;
}

ll lower(ll av) {
    ll st = 1, en = n, res, ps;
    while(st <= en) {
        ll mid = (st + en) / 2;
        if(h[mid] <= av) {
            ps = mid;
            st = mid + 1;
        }
        else en = mid - 1;
    }

    res = (ps * av) - cm[ps];
    return res;
}

ll solve(ll av) {
    ll c1 = lower(av);
    ll c2 = upper(av);
//    if(av == 3) cout << c1 << " " << c2 << "\n";

    ll op = min(c1, c2);
    if(m > (a+r)) op = 0;
//    ll op1 = op;

    ll t = op * m;
    t += ((c1-op) * a);
    t += ((c2-op) * r);
    return t;
}

int main() {
    FR;
    ll t = 0, x, y, z, i, j, k, g, p, q, ans = INF, sum = 0, c = 0;
    string s, s1, s2;

    cin >> n >> a >> r >> m;
    for1(i, n) cin >> h[i];

    sort(h+1, h+n+1);

    for1(i, n) cm[i] = cm[i-1] + h[i];

//    if(m < (a+r)) {
        ans = 0;
        x = cm[n] / n;
        for1(i, n) h1[i] = x;
        c = cm[n]%n;
        for(i = n-c+1; i <= n; i++) h1[i]++;

        c = 0;
        for1(i, n) c += abs(h[i]-h1[i]);
        c /= 2;
        ans = (c * m);

        t = c = 0;
        for1(i, n) {
            if(h1[i] != h1[1]) t += r;
            if(h1[i] != h1[n]) c += a;
        }

        ans += min(t, c);
//    }

//    ll st = 0, en = 1e9;

    for1(i, n) {
        c = solve(h[i]);
//        printl(c);
        if(c < ans) ans = c;
    }

    cout << ans << "\n";

    return 0;
}


//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;

//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll
#define sqr(x) ((x) * (x))
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, A, R, M, a[N], b[N];
ll ans = inf;

inline ll f (int x) {
   for (int i = 1; i <= n; i ++) b[i] = a[i];
   int res = 0;
   if (A + R <= M) {
      for (int i = 1; i <= n; i ++) {
         if (b[i] > x) res += (b[i] - x) * R;
         if (b[i] < x) res += (x - b[i]) * A;
      }
   }
   else {
      int it = n;
      for (int i = 1; i <= n; i ++) {
         if (b[i] < x) {
            if (it >= 1 && b[it] > x) {
               int mn = min (x - b[i], b[it] - x);
               b[i] += mn;
               b[it] -= mn;
               res += mn * M;
            }
            while (it >= 1 && b[it] <= x) it --;
         }
      }
      for (int i = 1; i <= n; i ++) {
         if (b[i] > x) res += (b[i] - x) * R;
         if (b[i] < x) res += (x - b[i]) * A;
      }
   }
   return res;
}

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}

inline void Solve () {
   cin >> n >> A >> R >> M;
   for (int i = 1; i <= n; i ++) cin >> a[i];
   sort (a + 1, a + n + 1);
   int l = 0, r = mod;
   while (r - l > 100) {
      int m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
      if (f (m1) < f (m2)) l = m1;
      else r = m2;
   }
   for (int i = l; i <= r; i ++) ans = min (ans, f (i));
   cout << ans;
}

signed main () {
// freopen (".in", "r", stdin);
// freopen (".out", "w", stdout);
   boost ();
   int tt = 1;
   //cin >> tt;
   while (tt --) {
      Solve ();
   }
   return 0;
}


//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;

//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll
#define sqr(x) ((x) * (x))
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, A, R, M, a[N], b[N];
ll ans = inf;

inline ll f (int x) {
   for (int i = 1; i <= n; i ++) b[i] = a[i];
   int res = 0;
   if (A + R <= M) {
      for (int i = 1; i <= n; i ++) {
         if (b[i] > x) res += (b[i] - x) * R;
         if (b[i] < x) res += (x - b[i]) * A;
      }
   }
   else {
      int it = n;
      for (int i = 1; i <= n; i ++) {
         if (b[i] < x) {
            if (it >= 1 && b[it] > x) {
               int mn = min (x - b[i], b[it] - x);
               b[i] += mn;
               b[it] -= mn;
               res += mn * M;
            }
            while (it >= 1 && b[it] <= x) it --;
         }
      }
      for (int i = 1; i <= n; i ++) {
         if (b[i] > x) res += (b[i] - x) * R;
         if (b[i] < x) res += (x - b[i]) * A;
      }
   }
   return res;
}

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}

inline void Solve () {
   cin >> n >> A >> R >> M;
   for (int i = 1; i <= n; i ++) cin >> a[i];
   sort (a + 1, a + n + 1);
   int l = 0, r = mod;
   while (r - l > 10) {
      int m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
      if (f (m1) < f (m2)) r = m2;
      else l = m1;
   }
   for (int i = l; i <= r; i ++) ans = min (ans, f (i));
   cout << ans;
}

signed main () {
// freopen (".in", "r", stdin);
// freopen (".out", "w", stdout);
   boost ();
   int tt = 1;
   //cin >> tt;
   while (tt --) {
      Solve ();
   }
   return 0;
}


//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;

//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll
#define sqr(x) ((x) * (x))
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, A, R, M, a[N], b[N];
ll ans = inf;

inline ll f (int x) {
   for (int i = 1; i <= n; i ++) b[i] = a[i];
   int res = 0;
   if (A + R <= M) {
      for (int i = 1; i <= n; i ++) {
         if (b[i] > x) res += (b[i] - x) * R;
         if (b[i] < x) res += (x - b[i]) * A;
      }
   }
   else {
      int it = n;
      for (int i = 1; i <= n; i ++) {
         if (b[i] < x) {
            if (it >= 1 && b[it] > x) {
               int mn = min (x - b[i], b[it] - x);
               b[i] += mn;
               b[it] -= mn;
               res += mn * M;
            }
            while (it >= 1 && b[it] <= x) it --;
         }
      }
      for (int i = 1; i <= n; i ++) {
         if (b[i] > x) res += (b[i] - x) * R;
         if (b[i] < x) res += (x - b[i]) * A;
      }
   }
   return res;
}

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}

inline void Solve () {
   cin >> n >> A >> R >> M;
   for (int i = 1; i <= n; i ++) cin >> a[i];
   sort (a + 1, a + n + 1);
   int l = 0, r = inf;
   while (r - l > 100) {
      int m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
      if (f (m1) < f (m2)) r = m2;
      else l = m1;
   }
   for (int i = l; i <= r; i ++) ans = min (ans, f (i));
   cout << ans;
}

signed main () {
// freopen (".in", "r", stdin);
// freopen (".out", "w", stdout);
   boost ();
   int tt = 1;
   //cin >> tt;
   while (tt --) {
      Solve ();
   }
   return 0;
}


//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;

//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll
#define sqr(x) ((x) * (x))
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, A, R, M, a[N], b[N];
ll ans = inf;

inline ll f (int x) {
   for (int i = 1; i <= n; i ++) b[i] = a[i];
   int res = 0;
   if (A + R <= M) {
      for (int i = 1; i <= n; i ++) {
         if (b[i] > x) res += (b[i] - x) * R;
         if (b[i] < x) res += (x - b[i]) * A;
      }
   }
   else {
      int it = n;
      for (int i = 1; i <= n; i ++) {
         if (b[i] < x) {
            if (it >= 1 && b[it] > x) {
               int mn = min (x - b[i], b[it] - x);
               b[i] += mn;
               b[it] -= mn;
               res += mn * M;
            }
            while (it >= 1 && b[it] <= x) it --;
         }
      }
      for (int i = 1; i <= n; i ++) {
         if (b[i] > x) res += (b[i] - x) * R;
         if (b[i] < x) res += (x - b[i]) * A;
      }
   }
   return res;
}

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}

inline void Solve () {
   cin >> n >> A >> R >> M;
   for (int i = 1; i <= n; i ++) cin >> a[i];
   sort (a + 1, a + n + 1);
   int l = 0, r = mod;
   while (r - l > 100) {
      int m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
      if (f (m1) < f (m2)) r = m2;
      else l = m1;
   }
   for (int i = l; i <= r; i ++) ans = min (ans, f (i));
   cout << ans;
}

signed main () {
// freopen (".in", "r", stdin);
// freopen (".out", "w", stdout);
   boost ();
   int tt = 1;
   //cin >> tt;
   while (tt --) {
      Solve ();
   }
   return 0;
}


//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;

//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll
#define sqr(x) ((x) * (x))
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, A, R, M, a[N], b[N];
ll ans = inf;

inline ll f (int x) {
   for (int i = 1; i <= n; i ++) b[i] = a[i];
   int res = 0;
   if (A + R <= M) {
      for (int i = 1; i <= n; i ++) {
         if (b[i] > x) res += (b[i] - x) * R;
         if (b[i] < x) res += (x - b[i]) * A;
      }
   }
   else {
      int it = n;
      for (int i = 1; i <= n; i ++) {
         if (b[i] < x) {
            if (it >= 1 && b[it] > x) {
               int mn = min (x - b[i], b[it] - x);
               b[i] += mn;
               b[it] -= mn;
               res += mn * M;
            }
            while (it >= 1 && b[it] <= x) it --;
            if (b[i] < x && b[it] > x) i --;
         }
      }
      for (int i = 1; i <= n; i ++) {
         if (b[i] > x) res += (b[i] - x) * R;
         if (b[i] < x) res += (x - b[i]) * A;
      }
   }
   return res;
}

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}

inline void Solve () {
   cin >> n >> A >> R >> M;
   for (int i = 1; i <= n; i ++) cin >> a[i];
   sort (a + 1, a + n + 1);
   int l = 0, r = mod;
   while (r - l > 10) {
      int m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
      if (f (m1) < f (m2)) r = m2;
      else l = m1;
   }
   for (int i = l; i <= r; i ++) ans = min (ans, f (i));
   cout << ans;
}

signed main () {
// freopen (".in", "r", stdin);
// freopen (".out", "w", stdout);
   boost ();
   int tt = 1;
   //cin >> tt;
   while (tt --) {
      Solve ();
   }
   return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define MAX 500005
#define INF 1e18
ll h[MAX];
ll n, a, r, m;

ll calc(ll x)
{
    ll kom = 0, beshi = 0;
    for(int i=0; i<n; i++){
        if(h[i] > x) beshi += (h[i]-x);
        if(h[i] < x) kom += (x-h[i]);
    }
    ll cost = 0;
    if(m <= a+r){
        ll t = min(beshi, kom);
        beshi -= t;
        kom -= t;
        cost += t*m;
    }
    cost += kom*a;
    cost += beshi*r;
    return cost;
}

int main()
{
    scanf("%lld %lld %lld %lld", &n, &a, &r, &m);
    for(int i=0; i<n; i++){
        scanf("%lld", &h[i]);
    }
    ll low = 0, high = 1e15, best = INF;
    while(low <= high){
        ll mid1 = (2*low+high)/3;
        ll mid2 = (low+2*high)/3;
        ll x = calc(mid1), y = calc(mid2);
        //cout << low << " " << mid1 << " " << mid2 << " " << high << " " << x << " " << y << endl;
        if(x < y){
            best = x;
            high = mid2-1;
        }
        else {
            best = y;
            low = mid1+1;
        }
    }
    cout << best;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define MAX 500005
#define INF 1e18
ll h[MAX];
ll n, a, r, m;

ll calc(ll x)
{
    ll kom = 0, beshi = 0;
    for(int i=0; i<n; i++){
        if(h[i] > x) beshi += (h[i]-x);
        if(h[i] < x) kom += (x-h[i]);
    }
    ll cost = 0;
    if(m <= a+r){
        ll t = min(beshi, kom);
        beshi -= t;
        kom -= t;
        cost += t*m;
    }
    cost += kom*a;
    cost += beshi*r;
    return cost;
}

int main()
{
    scanf("%lld %lld %lld %lld", &n, &a, &r, &m);
    for(int i=0; i<n; i++){
        scanf("%lld", &h[i]);
    }
    ll low = 0, high = 2e9, best = INF;
    while(low <= high){
        ll mid1 = (2*low+high)/3;
        ll mid2 = (low+2*high)/3;
        ll x = calc(mid1), y = calc(mid2);
        //cout << low << " " << mid1 << " " << mid2 << " " << high << " " << x << " " << y << endl;
        if(x < y){
            best = x;
            high = mid2-1;
        }
        else {
            best = y;
            low = mid1+1;
        }
        if(high-low<10){
            for(int x=low; x<=high; x++) best = min(best, calc(x));
            break;
        }
    }
    cout << best;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define MAX 500005
#define INF 1e18
ll h[MAX];
ll n, a, r, m;

ll calc(ll x)
{
    ll kom = 0, beshi = 0;
    for(int i=0; i<n; i++){
        if(h[i] > x) beshi += (h[i]-x);
        if(h[i] < x) kom += (x-h[i]);
    }
    ll cost = 0;
    if(m <= a+r){
        ll t = min(beshi, kom);
        beshi -= t;
        kom -= t;
        cost += t*m;
    }
    cost += kom*a;
    cost += beshi*r;
    return cost;
}

int main()
{
    scanf("%lld %lld %lld %lld", &n, &a, &r, &m);
    for(int i=0; i<n; i++){
        scanf("%lld", &h[i]);
    }
    ll low = 0, high = 2e9, best = INF;
    while(low <= high){
        ll mid1 = (2*low+high)/3;
        ll mid2 = (low+2*high)/3;
        ll x = calc(mid1), y = calc(mid2);
        //cout << low << " " << mid1 << " " << mid2 << " " << high << " " << x << " " << y << endl;
        if(x < y){
            best = x;
            high = mid2;
        }
        else {
            best = y;
            low = mid1;
        }
        if(high-low<10){
            for(int x=low; x<=high; x++) best = min(best, calc(x));
            break;
        }
    }
    cout << best;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define MAX 500005
#define INF 1e18
ll h[MAX];
ll n, a, r, m;

ll calc(ll x)
{
    ll kom = 0, beshi = 0;
    for(int i=0; i<n; i++){
        if(h[i] > x) beshi += (h[i]-x);
        if(h[i] < x) kom += (x-h[i]);
    }
    ll cost = 0;
    if(m <= a+r){
        ll t = min(beshi, kom);
        beshi -= t;
        kom -= t;
        cost += t*m;
    }
    cost += kom*a;
    cost += beshi*r;
    return cost;
}

int main()
{
    scanf("%lld %lld %lld %lld", &n, &a, &r, &m);
    for(int i=0; i<n; i++){
        scanf("%lld", &h[i]);
    }
    ll low = 0, high = 1e10, best = INF;
    while(low <= high){
        ll mid1 = (2*low+high)/3;
        ll mid2 = (low+2*high)/3;
        ll x = calc(mid1), y = calc(mid2);
        //cout << low << " " << mid1 << " " << mid2 << " " << high << " " << x << " " << y << endl;
        if(x < y){
            best = x;
            high = mid2-1;
        }
        else {
            best = y;
            low = mid1+1;
        }
    }
    cout << best;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define MAX 500005
#define INF 1e18
ll h[MAX];
ll n, a, r, m;

ll calc(ll x)
{
    ll kom = 0, beshi = 0;
    for(int i=0; i<n; i++){
        if(h[i] > x) beshi += (h[i]-x);
        if(h[i] < x) kom += (x-h[i]);
    }
    ll cost = 0;
    if(m <= a+r){
        ll t = min(beshi, kom);
        beshi -= t;
        kom -= t;
        cost += t*m;
    }
    cost += kom*a;
    cost += beshi*r;
    return cost;
}

int main()
{
    //freopen("in.txt", "r", stdin);
    scanf("%lld %lld %lld %lld", &n, &a, &r, &m);
    for(int i=0; i<n; i++){
        scanf("%lld", &h[i]);
    }
    ll low = 0, high = 1e9, best = INF;
    while(low <= high){
        ll mid1 = low + (high-low)/3;
        ll mid2 = high - (high-low)/3;
        ll x = calc(mid1), y = calc(mid2);
        if(x < y){
            best = x;
            high = mid2-1;
        }
        else {
            best = y;
            low = mid1+1;
        }
    }
    cout << best;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define MAX 500005
#define INF 1e18
ll h[MAX];
ll n, a, r, m;

ll calc(ll x)
{
    ll kom = 0, beshi = 0;
    for(int i=0; i<n; i++){
        if(h[i] > x) beshi += (h[i]-x);
        if(h[i] < x) kom += (x-h[i]);
    }
    ll cost = 0;
    if(m <= a+r){
        ll t = min(beshi, kom);
        beshi -= t;
        kom -= t;
        cost += t*m;
    }
    cost += kom*a;
    cost += beshi*r;
    return cost;
}

int main()
{
    scanf("%lld %lld %lld %lld", &n, &a, &r, &m);
    for(int i=0; i<n; i++){
        scanf("%lld", &h[i]);
    }
    ll low = 0, high = 2e9, best = INF;
    while(low <= high){
        ll mid1 = (2*low+high)/3;
        ll mid2 = (low+2*high)/3;
        ll x = calc(mid1), y = calc(mid2);
        //cout << low << " " << mid1 << " " << mid2 << " " << high << " " << x << " " << y << endl;
        if(x < y){
            best = x;
            high = mid2-1;
        }
        else {
            best = y;
            low = mid1+1;
        }
    }
    cout << best;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define MAX 500005
#define INF 1e18
ll h[MAX];
ll n, a, r, m;

ll calc(ll x)
{
    ll kom = 0, beshi = 0;
    for(int i=0; i<n; i++){
        if(h[i] > x) beshi += (h[i]-x);
        if(h[i] < x) kom += (x-h[i]);
    }
    ll cost = 0;
    if(m <= a+r){
        ll t = min(beshi, kom);
        beshi -= t;
        kom -= t;
        cost += t*m;
    }
    cost += kom*a;
    cost += beshi*r;
    return cost;
}

int main()
{
    scanf("%lld %lld %lld %lld", &n, &a, &r, &m);
    for(int i=0; i<n; i++){
        scanf("%lld", &h[i]);
    }
    ll low = 0, high = INF, best = INF;
    while(low <= high){
        ll mid1 = (2*low+high)/3;
        ll mid2 = (low+2*high)/3;
        ll x = calc(mid1), y = calc(mid2);
        //cout << low << " " << mid1 << " " << mid2 << " " << high << " " << x << " " << y << endl;
        if(x < y){
            best = x;
            high = mid2-1;
        }
        else {
            best = y;
            low = mid1+1;
        }
    }
    cout << best;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+5;
ll h[N],pref[N],A,R,M,n;
ll solve(ll H)
{
      ll pos=lower_bound(h,h+n,H)-h;
      ll k1=pos*H-pref[pos];
      ll k2=pref[n]-pref[pos]-(n-pos)*H;
      ll res=min(k1,k2);
     k1-=res; k2-=res;
     res=res*M;
     res+=k1*A;
     res+=k2*R;
     return res;

}
int main()
{
      ll ans=INF; cin>>n>>A>>R>>M;
      M=min(M,A+R);
      for(int i=0;i<n;i++) cin>>h[i];
      sort(h,h+n);
      pref[0]=0;
      for(int i=0;i<n;i++) pref[i+1]=pref[i]+h[i];
      ans=min(ans,solve(pref[n]/n));
      ans=min(ans,solve(pref[n]/(n+1)));
      for(int i=0;i<n;i++)
     { ans=min(ans,solve(h[i]));}
     cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+5;
const ll INF=(ll)2e18+77;
ll h[N],pref[N],A,R,M,n;
ll solve(ll H)
{
      ll pos=lower_bound(h,h+n,H)-h;
      ll k1=pos*H-pref[pos];
      ll k2=pref[n]-pref[pos]-(n-pos)*H;
      ll res=min(k1,k2);
     k1-=res; k2-=res;
     res=res*M;
     res+=k1*A;
     res+=k2*R;
     return res;

}
int main()
{
      ll ans=INF; cin>>n>>A>>R>>M;
      M=min(M,A+R);
      for(int i=0;i<n;i++) cin>>h[i];
      sort(h,h+n);
      pref[0]=0;
      for(int i=0;i<n;i++) pref[i+1]=pref[i]+h[i];
      ans=min(ans,solve(pref[n]/n));
      ans=min(ans,solve(pref[n]/(n+1)));
      for(int i=0;i<n;i++)
     { ans=min(ans,solve(h[i]));}
     cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=1e5+5;
const ll INF=(ll)2e18+77;
ll h[N],pref[N],A,R,M,n;
ll solve(ll H)
{
      ll pos=lower_bound(h,h+n,H)-h;
      ll k1=pos*H-pref[pos];
      ll k2=pref[n]-pref[pos]-(n-pos)*H;
      ll res=min(k1,k2);
     k1-=res; k2-=res;
     res=res*M;
     res+=k1*A;
     res+=k2*R;
     return res;

}
int main()
{
      ll ans=INF; cin>>n>>A>>R>>M;
      M=min(M,A+R);
      for(ll i=0;i<n;i++) cin>>h[i];
      sort(h,h+n);
      pref[0]=0;
      for(ll i=0;i<n;i++) pref[i+1]=pref[i]+h[i];
      ans=min(ans,solve(pref[n]/n));
      ans=min(ans,solve(pref[n]/n+1));
      for(ll i=0;i<n;i++)
     { ans=min(ans,solve(h[i]));}
     cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+5;
ll h[N],pref[N],A,R,M,n;
int solve(int H)
{
      int pos=lower_bound(h,h+n,H)-h;
      int k1=pos*H-pref[pos];
      int k2=pref[n]-pref[pos]-(n-pos)*H;
      int res=min(k1,k2);
     k1-=res; k2-=res;
     res=res*M;
     res+=k1*A;
     res+=k2*R;
     return res;

}
int main()
{
      ll ans=1e6; cin>>n>>A>>R>>M;
      M=min(M,A+R);
      for(int i=0;i<n;i++) cin>>h[i];
      sort(h,h+n);
      pref[0]=0;
      for(int i=0;i<n;i++) pref[i+1]=pref[i]+h[i];
      ans=min(ans,solve(pref[n]/n));
      ans=min(ans,solve(pref[n]/(n+1)));
      for(int i=0;i<n;i++)
     { ans=min(ans,solve(h[i]));}
     cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+5;
ll h[N],pref[N],A,R,M,n;
ll solve(ll H)
{
      ll pos=lower_bound(h,h+n,H)-h;
      ll k1=pos*H-pref[pos];
      ll k2=pref[n]-pref[pos]-(n-pos)*H;
      ll res=min(k1,k2);
     k1-=res; k2-=res;
     res=res*M;
     res+=k1*A;
     res+=k2*R;
     return res;

}
int main()
{
      ll ans=10000000000; cin>>n>>A>>R>>M;
      M=min(M,A+R);
      for(int i=0;i<n;i++) cin>>h[i];
      sort(h,h+n);
      pref[0]=0;
      for(int i=0;i<n;i++) pref[i+1]=pref[i]+h[i];
      ans=min(ans,solve(pref[n]/n));
      ans=min(ans,solve(pref[n]/(n+1)));
      for(int i=0;i<n;i++)
     { ans=min(ans,solve(h[i]));}
     cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+5;
ll h[N],pref[N],A,R,M,n;
ll solve(ll H)
{
      ll pos=lower_bound(h,h+n,H)-h;
      ll k1=pos*H-pref[pos];
      ll k2=pref[n]-pref[pos]-(n-pos)*H;
      ll res=min(k1,k2);
     k1-=res; k2-=res;
     res=res*M;
     res+=k1*A;
     res+=k2*R;
     return res;

}
int main()
{
      ll ans=1e6; cin>>n>>A>>R>>M;
      M=min(M,A+R);
      for(int i=0;i<n;i++) cin>>h[i];
      sort(h,h+n);
      pref[0]=0;
      for(int i=0;i<n;i++) pref[i+1]=pref[i]+h[i];
      ans=min(ans,solve(pref[n]/n));
      ans=min(ans,solve(pref[n]/(n+1)));
      for(int i=0;i<n;i++)
     { ans=min(ans,solve(h[i]));}
     cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=1e5+5;
const ll INF=(ll)2e18+77;
ll h[N],pref[N],A,R,M,n;
ll solve(ll H)
{
      ll pos=lower_bound(h,h+n,H)-h;
      ll k1=pos*H-pref[pos];
      ll k2=pref[n]-pref[pos]-(n-pos)*H;
      ll res=min(k1,k2);
     k1-=res; k2-=res;
     res=res*M;
     res+=k1*A;
     res+=k2*R;
     return res;

}
int main()
{
      ll ans=INF; cin>>n>>A>>R>>M;
      M=min(M,A+R);
      for(ll i=0;i<n;i++) cin>>h[i];
      sort(h,h+n);
      pref[0]=0;
      for(ll i=0;i<n;i++) pref[i+1]=pref[i]+h[i];
      ans=min(ans,solve(pref[n]/n));
      ans=min(ans,solve(pref[n]/n+1)));
      for(ll i=0;i<n;i++)
     { ans=min(ans,solve(h[i]));}
     cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+5;
const ll INF=2e18+77;
ll h[N],pref[N],A,R,M,n;
ll solve(ll H)
{
      ll pos=lower_bound(h,h+n,H)-h;
      ll k1=pos*H-pref[pos];
      ll k2=pref[n]-pref[pos]-(n-pos)*H;
      ll res=min(k1,k2);
     k1-=res; k2-=res;
     res=res*M;
     res+=k1*A;
     res+=k2*R;
     return res;

}
int main()
{
      ll ans=INF; cin>>n>>A>>R>>M;
      M=min(M,A+R);
      for(int i=0;i<n;i++) cin>>h[i];
      sort(h,h+n);
      pref[0]=0;
      for(int i=0;i<n;i++) pref[i+1]=pref[i]+h[i];
      ans=min(ans,solve(pref[n]/n));
      ans=min(ans,solve(pref[n]/(n+1)));
      for(int i=0;i<n;i++)
     { ans=min(ans,solve(h[i]));}
     cout<<ans;
}


#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define intl long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define S(x) (int) x.size()
#define LB lower_bound
#define UB upper_bound
#define fp(x, y) fixed<<setprecision(y)<<x
#define M 100005
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884
using namespace std;

int main(){
  int n, a, r, m;
  cin>>n>>a>>r>>m;
  int h[n], A[n];
  intl ans=0;
  for (int i=0; i<n; i++) {
    cin>>h[i];
    A[i]=h[i];
  }
  sort(h, h+n);
  if (a<=r){
    int x=h[n-1];
    for (int i=0; i<n-1; i++) ans+=(x-h[i])*a;
  }
  else if (r<a){
    int x=h[0];
    for (int i=1; i<n; i++) ans+=(h[i]-x)*r;
  }
  intl avg=0, t=0;
  for (int i=0; i<n; i++) avg+=h[i];
  avg=avg/n;
  int i=0, j=n-1;
  while(A[i]<avg && A[j]>avg){
    while(A[j]>avg && A[i]<avg){
      A[j]--; A[i]++;
      t+=m;
    }
    if (A[j]==avg) j--;
    if (A[i]==avg) i++;
  }
  for (int k=0; k<n; k++){
    if (A[k]-avg>0) t+=(A[k]-avg)*r;
    else if (A[k]-avg<0) t+=(avg-A[k])*a;
  }
  ans=min(ans, t);
  int x=h[n/2];
  if (a+r<=m){
    t=0;
    for (int i=0; i<n/2; i++) t+=(x-h[i])*a;
    for (int i=n/2+1; i<n; i++) t+=(h[i]-x)*r;
    ans=min(ans, t);
  }
  else{
    i=0; j=n-1;
    t=0;
    while(i<n/2 && j>n/2){
      while(h[j]!=x && h[i]!=x){
        h[j]--; h[i]++;
        t+=m;
      }
      if (h[j]==x) j--;
      if (h[i]==x) i++;
    }
    if (j>n/2){
      for (int k=n/2+1; k<=j; k++) t+=(h[k]-x)*r;
    }
    else if (i<n/2){
      for (int k=i; k<n/2; k++) t+=(x-h[k])*a;
    }
    ans=min(ans, t);
  }
  cout<<ans<<endl;
  return 0;
}


#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define intl long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define S(x) (int) x.size()
#define LB lower_bound
#define UB upper_bound
#define fp(x, y) fixed<<setprecision(y)<<x
#define M 100005
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884
using namespace std;

int main(){
  intl n, a, r, m;
  cin>>n>>a>>r>>m;
  int h[n];
  intl pre[n];
  for (int i=0; i<n; i++) cin>>h[i];
  sort(h, h+n);
  m=min(a+r, m);
  pre[0]=h[0];
  for (int i=1; i<n; i++) pre[i]=pre[i-1]+h[i];
  intl p, q, ans=pre[n-1], avg;
  for (int i=0; i<n; i++){
    if (i>0) p=i*h[i]-pre[i-1];
    else p=0;
    q=pre[n-1]-pre[i]-(n-1-i)*h[i];
    if (p>=q) ans=min(ans, a*(p-q)+m*q);
    else ans=min(ans, r*(q-p)+m*p);
  }
  avg=pre[n-1]/n;
  intl i=0;
  while(h[i]<avg) i++;
  if (h[i]!=avg){
    p=i*avg-pre[i-1];
    q=pre[n-1]-pre[i-1]-(n-i)*avg;
    if (p>=q) ans=min(ans, a*(p-q)+m*q);
    else ans=min(ans, r*(q-p)+m*p);
  }
  if (pre[n-1]%n!=0){
    avg++;
    i=0;
    while(h[i]<avg) i++;
    if (h[i]!=avg){
      p=i*avg-pre[i-1];
      q=pre[n-1]-pre[i-1]-(n-i)*avg;
      if (p>=q) ans=min(ans, a*(p-q)+m*q);
      else ans=min(ans, r*(q-p)+m*p);
    }
  }
  cout<<ans<<endl;
  return 0;
}


#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define intl long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define S(x) (int) x.size()
#define LB lower_bound
#define UB upper_bound
#define fp(x, y) fixed<<setprecision(y)<<x
#define M 100005
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884
using namespace std;

int main(){
  intl n, a, r, m;
  cin>>n>>a>>r>>m;
  intl h[n];
  intl pre[n];
  for (int i=0; i<n; i++) cin>>h[i];
  sort(h, h+n);
  m=min(a+r, m);
  pre[0]=h[0];
  for (intl i=1; i<n; i++) pre[i]=pre[i-1]+h[i];
  intl p, q, ans=pre[n-1], avg;
  for (intl i=0; i<n; i++){
    if (i>0) p=i*h[i]-pre[i-1];
    else p=0;
    q=pre[n-1]-pre[i]-(n-1-i)*h[i];
    if (p>=q) ans=min(ans, a*(p-q)+m*q);
    else ans=min(ans, r*(q-p)+m*p);
  }
  avg=pre[n-1]/n;
  intl i=0;
  while(h[i]<avg) i++;
  if (h[i]!=avg){
    p=i*avg-pre[i-1];
    q=pre[n-1]-pre[i-1]-(n-i)*avg;
    if (p>=q) ans=min(ans, a*(p-q)+m*q);
    else ans=min(ans, r*(q-p)+m*p);
  }
  if (pre[n-1]%n!=0){
    avg++;
    i=0;
    while(h[i]<avg) i++;
    if (h[i]!=avg){
      p=i*avg-pre[i-1];
      q=pre[n-1]-pre[i-1]-(n-i)*avg;
      if (p>=q) ans=min(ans, a*(p-q)+m*q);
      else ans=min(ans, r*(q-p)+m*p);
    }
  }
  cout<<ans<<endl;
  return 0;
}


#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define intl long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define S(x) (int) x.size()
#define LB lower_bound
#define UB upper_bound
#define fp(x, y) fixed<<setprecision(y)<<x
#define M 100005
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884
using namespace std;

int main(){
  intl n, a, r, m;
  cin>>n>>a>>r>>m;
  intl h[n];
  intl pre[n];
  for (intl i=0; i<n; i++) cin>>h[i];
  sort(h, h+n);
  m=min(a+r, m);
  pre[0]=h[0];
  for (intl i=1; i<n; i++) pre[i]=pre[i-1]+h[i];
  intl p, q, ans=pre[n-1], avg;
  for (intl i=0; i<n; i++){
    if (i>0) p=i*h[i]-pre[i-1];
    else p=0;
    q=pre[n-1]-pre[i]-(n-1-i)*h[i];
    if (p>=q) ans=min(ans, a*(p-q)+m*q);
    else ans=min(ans, r*(q-p)+m*p);
  }
  avg=pre[n-1]/n;
  intl i=0;
  while(h[i]<avg) i++;
  if (h[i]!=avg){
    p=i*avg-pre[i-1];
    q=pre[n-1]-pre[i-1]-(n-i)*avg;
    if (p>=q) ans=min(ans, a*(p-q)+m*q);
    else ans=min(ans, r*(q-p)+m*p);
  }
  if (pre[n-1]%n!=0){
    avg++;
    i=0;
    while(h[i]<avg) i++;
    if (h[i]!=avg){
      p=i*avg-pre[i-1];
      q=pre[n-1]-pre[i-1]-(n-i)*avg;
      if (p>=q) ans=min(ans, a*(p-q)+m*q);
      else ans=min(ans, r*(q-p)+m*p);
    }
  }
  cout<<ans<<endl;
  return 0;
}


#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define intl long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define S(x) (int) x.size()
#define LB lower_bound
#define UB upper_bound
#define fp(x, y) fixed<<setprecision(y)<<x
#define M 100005
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884
using namespace std;

int main(){
  intl n, a, r, m;
  cin>>n>>a>>r>>m;
  intl h[n];
  intl pre[n];
  for (intl i=0; i<n; i++) cin>>h[i];
  sort(h, h+n);
  m=min(a+r, m);
  pre[0]=h[0];
  for (intl i=1; i<n; i++) pre[i]=pre[i-1]+h[i];
  intl p, q, ans=(intl)2e18 + 77, avg;
  for (intl i=0; i<n; i++){
    if (i>0) p=i*h[i]-pre[i-1];
    else p=0;
    q=pre[n-1]-pre[i]-(n-1-i)*h[i];
    if (p>=q) ans=min(ans, a*(p-q)+m*q);
    else ans=min(ans, r*(q-p)+m*p);
  }
  avg=pre[n-1]/n;
  intl i=0;
  while(h[i]<avg) i++;
  if (h[i]!=avg){
    p=i*avg-pre[i-1];
    q=pre[n-1]-pre[i-1]-(n-i)*avg;
    if (p>=q) ans=min(ans, a*(p-q)+m*q);
    else ans=min(ans, r*(q-p)+m*p);
  }
  if (pre[n-1]%n!=0){
    avg++;
    i=0;
    while(h[i]<avg) i++;
    if (h[i]!=avg){
      p=i*avg-pre[i-1];
      q=pre[n-1]-pre[i-1]-(n-i)*avg;
      if (p>=q) ans=min(ans, a*(p-q)+m*q);
      else ans=min(ans, r*(q-p)+m*p);
    }
  }
  cout<<ans<<endl;
  return 0;
}


#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define intl long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define S(x) (int) x.size()
#define LB lower_bound
#define UB upper_bound
#define fp(x, y) fixed<<setprecision(y)<<x
#define M 100005
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884
using namespace std;

int main(){
  int n, a, r, m;
  cin>>n>>a>>r>>m;
  int h[n];
  intl pre[n];
  for (int i=0; i<n; i++) cin>>h[i];
  sort(h, h+n);
  m=min(a+r, m);
  pre[0]=h[0];
  for (int i=1; i<n; i++) pre[i]=pre[i-1]+h[i];
  intl p, q, ans=pre[n-1], avg;
  for (int i=0; i<n; i++){
    if (i>0) p=i*h[i]-pre[i-1];
    else p=0;
    q=pre[n-1]-pre[i]-(n-1-i)*h[i];
    if (p>=q) ans=min(ans, a*(p-q)+m*q);
    else ans=min(ans, r*(q-p)+m*p);
  }
  avg=pre[n-1]/n;
  int i=0;
  while(h[i]<avg) i++;
  if (h[i]!=avg){
    p=i*avg-pre[i-1];
    q=pre[n-1]-pre[i-1]-(n-i)*avg;
    if (p>=q) ans=min(ans, a*(p-q)+m*q);
    else ans=min(ans, r*(q-p)+m*p);
  }
  if (pre[n-1]%n!=0){
    avg++;
    i=0;
    while(h[i]<avg) i++;
    if (h[i]!=avg){
      p=i*avg-pre[i-1];
      q=pre[n-1]-pre[i-1]-(n-i)*avg;
      if (p>=q) ans=min(ans, a*(p-q)+m*q);
      else ans=min(ans, r*(q-p)+m*p);
    }
  }
  cout<<ans<<endl;
  return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
int a[100002],A,R,M,N;
ll pre[100002],suf[100002],sum;
const ll INF=1e18;
int main(){
	cin>>N>>A>>R>>M; sum=0;
	for(int i=1;i<=N;i++) cin>>a[i],sum+=a[i];
	sort(a+1,a+N+1);
	ll na,nb,aa=0,ar=0;
	na=sum%N,nb=sum/N;
	for(int i=1;i<=N;i++){
		pre[i]+=pre[i-1]+a[i];
		suf[N-i+1]+=suf[N-i+2]+a[N-i+1];
		if(a[i]>nb){
			aa+=(a[i]-nb);
			if(na&&a[i]>(nb+1)) ar+=(a[i]-nb-1);
		}
	}
    ll ans=INF;
    {
    	ll asn=INF,asb=INF;
		if(A+R>M){
			asn=M*(aa-na)+R*na;
		    if(na!=0)	asb=M*ar+A*(N-na);
		}
		else{
			asn=(A+R)*(aa-na)+R*na;
			if(na!=0)   asb=(A+R)*ar+A*(N-na);
		}
		//cout<<asn<<"  "<<asb<<"   --> ";
		ans=min(min(asn,asb),ans);
		//cout<<ans<<"  -->"<<endl;
	}
	{
		for(int i=1;i<=N;i++){
			int j=i;
			while(j+1<=N&&a[j+1]==a[i]) j++;
			ll an1,an2,an,na;
			an1=(ll)a[i]*(i-1)-pre[i-1]; an2=suf[j+1]-(ll)a[i]*(N-j);
			an=A*an1+R*an2;
			if(an1<an2) na=M*an1+R*(an2-an1);
			else        na=M*an2+A*(an1-an2);
			ans=min(min(an,na),ans);
			i=j;
		}
	}
    cout<<ans<<endl;
return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
int a[100002],A,R,M,N;
ll pre[100002],suf[100002];
const ll INF=1e18;
int main(){
	cin>>N>>A>>R>>M;
	for(int i=1;i<=N;i++) cin>>a[i];
	sort(a+1,a+N+1);
	for(int i=1;i<=N;i++){
		pre[i]+=pre[i-1]+a[i];
		suf[N-i+1]+=suf[N-i+2]+a[N-i+1];
		//cout<<(N-i+1)<<"  --> "<<suf[N-i+1]<<endl;
	}
	const int maxn=2e5;
    ll ans=INF;
    {
    	ll na,nb,su=0,aa=0,ar=0,asn=maxn,asb=maxn,asc=maxn,asd=maxn;
    	na=pre[N]%N; nb=pre[N]/N;
        for(int i=N;i>=1;i--){
        	if(a[i]>nb){   aa+=(a[i]-nb);	}
			if(na!=0&&a[i]>(nb+1)){	  ar+=(a[i]-nb-1);	}
			if(a[i]<=nb) break;
		}
		if(A+R>M){
			asn=M*(aa-na)+R*na;
		    if(na!=0)	asb=M*ar+A*(N-na);
		}
		else{
			asn=(A+R)*(aa-na)+R*na;
			if(na!=0)   asb=(A+R)*ar+A*(N-na);
		}
		//cout<<asn<<"  "<<asb<<endl;
		ans=min(min(asn,asb),ans);
		//cout<<ans<<"  -->"<<endl;
	}
	{
		for(int i=1;i<=N;i++){
			int j=i;
			while(j+1<=N&&a[j+1]==a[i]) j++;
			ll an1,an2,an,na;
			an1=(ll)a[i]*(i-1)-pre[i-1]; an2=suf[j+1]-(ll)a[i]*(N-j);
			an=A*an1+R*an2;
			if(an1<an2) na=M*an1+R*(an2-an1);
			else        na=M*an2+A*(an1-an2);
			ans=min(min(an,na),ans);
			i=j;
		}
	}
    cout<<ans<<endl;
return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
int a[100002],A,R,M,N;
ll pre[100002],suf[100002],sum;
const ll INF=1e18;
int main(){
	cin>>N>>A>>R>>M; sum=0;
	for(int i=1;i<=N;i++) cin>>a[i],sum+=a[i];
	sort(a+1,a+N+1);
	ll na,nb,aa=0,ar=0;
	na=sum%N,nb=sum/N;
	for(int i=1;i<=N;i++){
		pre[i]+=pre[i-1]+a[i];
		suf[N-i+1]+=suf[N-i+2]+a[N-i+1];
		if(a[i]>nb){
			aa+=(a[i]-nb);
			if(na&&a[i]>(nb+1)) ar+=(a[i-nb-1]);
		}
	}
	ll maxn=INF;
    ll ans=INF;
    {
    	ll asn=maxn,asb=maxn;
		if(A+R>M){
			asn=M*(aa-na)+R*na;
		    if(na!=0)	asb=M*ar+A*(N-na);
		}
		else{
			asn=(A+R)*(aa-na)+R*na;
			if(na!=0)   asb=(A+R)*ar+A*(N-na);
		}
		//cout<<asn<<"  "<<asb<<"   --> ";
		ans=min(min(asn,asb),ans);
		//cout<<ans<<"  -->"<<endl;
	}
	{
		for(int i=1;i<=N;i++){
			int j=i;
			while(j+1<=N&&a[j+1]==a[i]) j++;
			ll an1,an2,an,na;
			an1=(ll)a[i]*(i-1)-pre[i-1]; an2=suf[j+1]-(ll)a[i]*(N-j);
			an=A*an1+R*an2;
			if(an1<an2) na=M*an1+R*(an2-an1);
			else        na=M*an2+A*(an1-an2);
			ans=min(min(an,na),ans);
			i=j;
		}
	}
    cout<<ans<<endl;
return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
int a[100002],A,R,M,N;
ll pre[100002],suf[100002];
const ll INF=1e18;
int main(){
	cin>>N>>A>>R>>M;
	for(int i=1;i<=N;i++) cin>>a[i];
	sort(a+1,a+N+1);
	for(int i=1;i<=N;i++){
		pre[i]+=pre[i-1]+a[i];
		suf[N-i+1]+=suf[N-i+2]+a[N-i+1];
		//cout<<(N-i+1)<<"  --> "<<suf[N-i+1]<<endl;
	}
    ll ans=INF;
	for(int i=1;i<=N;++i){
		int j=i;
		while(j+1<=N&&a[j+1]==a[i])++j;
		//cout<<j<<"  --> "<<a[i]<<"  --> ";
		ll  ana,anr,anm,asn;
		anr=(ll)a[i]*(i-1)-pre[i-1]; anm=suf[j+1]-(ll)a[i]*(N-j);
		ana=A*anr+R*anm;
		if(anr<anm) asn=M*anr+R*(anm-anr);
		else        asn=M*anm+A*(anr-anm);
		ans=min(ans,min(ana,asn));
		//cout<<ans<<"  -->"<<endl;
		i=j;
	}cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
int a[100002],A,R,M,N;
ll pre[100002],suf[100002];
const ll INF=1e18;
int main(){
	cin>>N>>A>>R>>M;
	for(int i=1;i<=N;i++) cin>>a[i];
	sort(a+1,a+N+1);
	for(int i=1;i<=N;i++){
		pre[i]+=pre[i-1]+a[i];
		suf[N-i+1]+=suf[N-i+2]+a[N-i+1];
		//cout<<(N-i+1)<<"  --> "<<suf[N-i+1]<<endl;
	}
    ll ans=INF;
    {
    	ll na,nb,su=0,aa=0,ar=0,asn=0,asb=0;
    	na=pre[N]%N; nb=pre[N]/N;
        for(int i=N;i>=1;i--){
        	if(a[i]>nb){   aa+=(a[i]-nb);	}
			if(na!=0&&a[i]>(nb+1)){	  ar+=(a[i]-nb-1);	}
			if(a[i]<=nb) break;
		}
		asn=M*(aa-na)+R*na;   asb=M*ar+A*(N-na);
		ans=min(asn,asb);
		//cout<<ans<<"  -->"<<endl;
	}
	{
		for(int i=1;i<=N;++i){
		    int j=i;
		    while(j+1<=N&&a[j+1]==a[i])++j;
		    //cout<<j<<"  --> "<<a[i]<<"  --> ";
		    ll  ana,anr,anm,asn;
		    anr=(ll)a[i]*(i-1)-pre[i-1]; anm=suf[j+1]-(ll)a[i]*(N-j);
		    ana=A*anr+R*anm;
		    ans=min(ans,ana);
		    //cout<<ans<<"  -->"<<endl;
		    i=j;
	    }
	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
int a[100002],A,R,M,N;
ll pre[100002],suf[100002];
const ll INF=1e18;
int main(){
	cin>>N>>A>>R>>M;
	for(int i=1;i<=N;i++) cin>>a[i];
	sort(a+1,a+N+1);
	for(int i=1;i<=N;i++){
		pre[i]+=pre[i-1]+a[i];
		suf[N-i+1]+=suf[N-i+2]+a[N-i+1];
		//cout<<(N-i+1)<<"  --> "<<suf[N-i+1]<<endl;
	}
    ll ans=INF;
    if((A+R)>M){
    	ll na,nb,su=0,aa,ar,asn,asb;
    	na=pre[N]%N; nb=pre[N]/N;
        for(int i=1;i<=N;i++){
        	if(a[i]<nb){   aa+=(nb-a[i]);	}
			if(na!=0&&a[i]<(nb+1)){	  ar+=(nb-a[i]+1);	}
			if(a[i]>=nb||a[i]>=(nb+1)) break;
		}
		asn=M*aa+R*na;   asb=M*ar+A*(N-na);
		ans=min(asn,asb);
	}
	else{
		for(int i=1;i<=N;++i){
		    int j=i;
		    while(j+1<=N&&a[j+1]==a[i])++j;
		    //cout<<j<<"  --> "<<a[i]<<"  --> ";
		    ll  ana,anr,anm,asn;
		    anr=(ll)a[i]*(i-1)-pre[i-1]; anm=suf[j+1]-(ll)a[i]*(N-j);
		    ana=A*anr+R*anm;
		    ans=min(ans,ana);
		    //cout<<ans<<"  -->"<<endl;
		    i=j;
	    }
	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
int a[100002],A,R,M,N;
ll pre[100002],suf[100002];
const ll INF=1e18;
int main(){
	cin>>N>>A>>R>>M;
	for(int i=1;i<=N;i++) cin>>a[i];
	sort(a+1,a+N+1);
	for(int i=1;i<=N;i++){
		pre[i]+=pre[i-1]+a[i];
		suf[N-i+1]+=suf[N-i+2]+a[N-i+1];
		//cout<<(N-i+1)<<"  --> "<<suf[N-i+1]<<endl;
	}
	const int maxn=2e5;
    ll ans=INF;
    {
    	ll na,nb,su=0,aa=0,ar=0,asn=maxn,asb=maxn;
    	na=pre[N]%N; nb=pre[N]/N;
        for(int i=N;i>=1;i--){
        	if(a[i]>nb){   aa+=(a[i]-nb);	}
			if(na!=0&&a[i]>(nb+1)){	  ar+=(a[i]-nb-1);	}
			if(a[i]<=nb) break;
		}
		asn=M*(aa-na)+R*na;
		if(na!=0)	asb=M*ar+A*(N-na);
		//cout<<asn<<"  "<<asb<<endl;
		ans=min(asn,asb);
		//cout<<ans<<"  -->"<<endl;
	}
	{
		for(int i=1;i<=N;++i){
		    int j=i;
		    while(j+1<=N&&a[j+1]==a[i])++j;
		    //cout<<j<<"  --> "<<a[i]<<"  --> ";
		    ll  ana,anr,anm,asn;
		    anr=(ll)a[i]*(i-1)-pre[i-1]; anm=suf[j+1]-(ll)a[i]*(N-j);
		    ana=A*anr+R*anm;
		    ans=min(ans,ana);
		    //cout<<ans<<"  -->"<<endl;
		    i=j;
	    }
	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
int a[100002],A,R,M,N;
ll pre[100002],suf[100002];
const ll INF=1e18;
int main(){
	cin>>N>>A>>R>>M;
	for(int i=1;i<=N;i++) cin>>a[i];
	sort(a+1,a+N+1);
	for(int i=1;i<=N;i++){
		pre[i]+=pre[i-1]+a[i];
		suf[N-i+1]+=suf[N-i+2]+a[N-i+1];
		//cout<<(N-i+1)<<"  --> "<<suf[N-i+1]<<endl;
	}
	const int maxn=2e5;
    ll ans=INF;
    {
    	ll na,nb,su=0,aa=0,ar=0,asn=maxn,asb=maxn,asc=maxn,asd=maxn;
    	na=pre[N]%N; nb=pre[N]/N;
        for(int i=N;i>=1;i--){
        	if(a[i]>nb){   aa+=(a[i]-nb);	}
			if(na!=0&&a[i]>(nb+1)){	  ar+=(a[i]-nb-1);	}
			if(a[i]<=nb) break;
		}
		asn=M*(aa-na)+R*na;     asc=M*(ar-na)+R*na;
		if(na!=0)	asb=M*ar+A*(N-na),asd=M*aa+A*(N-na);
		//cout<<asn<<"  "<<asb<<endl;
		ans=min(min(asn,asb),min(asc,asd));
		//cout<<ans<<"  -->"<<endl;
	}
	{
		for(int i=1;i<=N;++i){
		    int j=i;
		    while(j+1<=N&&a[j+1]==a[i])++j;
		    //cout<<j<<"  --> "<<a[i]<<"  --> ";
		    ll  ana,anr,anm,asn;
		    anr=(ll)a[i]*(i-1)-pre[i-1]; anm=suf[j+1]-(ll)a[i]*(N-j);
		    ana=A*anr+R*anm;
		    ans=min(ans,ana);
		    //cout<<ans<<"  -->"<<endl;
		    i=j;
	    }
	}
	cout<<ans<<endl;
	return 0;
}