#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second

ll n,cnt,ans=LINF,a,l[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
vector<int> buf;

//-------------------------↓↓↓↓↓↓------------------------

void dfs(int i, const int size, const int range_start, const int range_end)
{
    if (i == size) {
        // ここで所望の作業を行う
        ll now[n+100]={};
        rep(i,n)now[i]=l[i];
        ll ok=1;
        rep(i,Size(buf)){
            if(now[buf[i]]==0)ok=0;
            now[buf[i]]+=now[buf[i+1]];
            now[buf[i+1]]=0;
        }
        if(ok){
        sort(now,now+n-3);
        reverse(now,now+n-3);
        cnt=0;
        cnt+=abs(a-now[0]);
        cnt+=abs(b-now[1]);
        cnt+=abs(c-now[2]);
        ans=min(ans,cnt);
        }
    }
    else{
        for(int j = range_start; j <= range_end; ++j){
            buf[i] = j;
            dfs(i + 1, size, range_start, range_end);
        }
    }
}

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

    cin>>n>>a>>b>>c;
    rep(i,n)cin>>l[i];
    ll need=n-3;
    dfs(0,need,0,n);
    Cout(ans);
    return 0;
}
