#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007

ll a,b,c;

ll solve(vector<ll> &v, ll tmp){
    ll i,j,k;
    ll n=v.size();
    ll s=1e10;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            for(k=0;k<n;k++){
                if(i==j||j==k||k==i) continue;
                s=min(s,tmp+abs(a-v[i])+abs(b-v[j])+abs(c-v[k]));
            }
        }
    }
    return s;
}

int main(){
    ll i,j;
    ll n;
    cin>>n>>a>>b>>c;

    ll l[n];
    for(i=0;i<n;i++) cin>>l[i];

    ll c[n];
    ll ans=1e10;

    for(i=0;i< (1<<(2*n));i++){
        ll ii=i;
        for(j=0;j<n;j++){
            c[j]=ii%4;
            ii=ii/4;
        }
        vector<ll> v;
        ll p=0,q=0,r=0;
        ll tmp=0;

        for(j=0;j<n;j++){
            if(c[j]==0) v.pb(l[j]);
            else if(c[j]==1) {
                if(p>0) tmp+=10;
                p+=l[j];
            }
            else if(c[j]==2) {
                if(q>0)  tmp+=10;
                q+=l[j];
            }
            else {
                if(r>0) tmp+=10;
                r+=l[j];
            }
        }
        if(p>0) v.pb(p);
        if(q>0) v.pb(q);
        if(r>0) v.pb(r);

        
        ans=min(ans,solve(v,tmp));

        


    }

    cout<<ans<<endl;
    