// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

using ll=long long;

using vb=vector<bool>;

using vvb=vector<vb>;

using vd=vector<double>;

using vvd=vector<vd>;

using vi=vector<int>;

using vvi=vector<vi>;

using vl=vector<ll>;

using vvl=vector<vl>;

using pll=pair<ll,ll>;

using tll=tuple<ll,ll>;

using tlll=tuple<ll,ll,ll>;

using vs=vector<string>;

#define all(a) a.begin(),a.end()

#define rall(a) a.rbegin(),a.rend()

#define rep(i,n) range(i,0,n)

#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)

#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)

#define INF ((int)1<<30)

#define EPS (1e-9)

#define MOD (1000000007ll)

#define fcout(a) cout<<setprecision(a)<<fixed

#define fs first

#define sc second

#define PI (3.1415926535897932384)



int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}

template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}

template<class S>S max(vector<S>&a){return *max_element(all(a));}

template<class S>S min(vector<S>&a){return *min_element(all(a));}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}



template<class T>void puta(T&&t){cout<<t<<"\n";}

template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}

void YN(bool b){tf(b,"YES","NO");}

void Yn(bool b){tf(b,"Yes","No");}

void yn(bool b){tf(b,"yes","no");}

template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};

template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}

template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}



/*他のライブラリを入れる場所*/

map<pair<vl,ll>,ll> mp;

ll solve(vl a,ll t){

	auto p=make_pair(a,t);

	if(mp.find(p)!=mp.end())return mp[p];

	int n=a.size();

	ll ret=LINF;

	rep(i,n){

		chmin(ret,abs(t-a[i]));

	}

	if(n==1)return mp[p]=ret;

	rep(i,n)range(j,i+1,n){

		vl nxt;

		rep(k,n)if(k!=j)nxt.push_back(a[k]);

		nxt[i]+=a[j];

		chmin(ret,solve(nxt,t)+10);

	}

	return mp[p]=ret;

}



int main(){

	cin.tie(0);

	ios::sync_with_stdio(false);

	ll n;

	cin>>n;

	vl t(3),a(n);

	cin>>t>>a;



	vvl ans(3,vl(1<<n,0));

	rep(i,3){

		rep(s,1<<n){

			vl tmp;

			rep(j,n)if(s&(1<<j))tmp.push_back(a[j]);

			ans[i][s]=solve(tmp,t[i]);

		}

	}

	ll v=LINF;

	rep(i,1<<n)rep(j,1<<n)rep(k,1<<n){

		if((i&j) or (j&k) or (k&i))continue;

		chmin(v,ans[0][i]+ans[1][j]+ans[2][k]);

	}

	puta(v);

	return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

using ll=long long;

using vb=vector<bool>;

using vvb=vector<vb>;

using vd=vector<double>;

using vvd=vector<vd>;

using vi=vector<int>;

using vvi=vector<vi>;

using vl=vector<ll>;

using vvl=vector<vl>;

using pll=pair<ll,ll>;

using tll=tuple<ll,ll>;

using tlll=tuple<ll,ll,ll>;

using vs=vector<string>;

#define all(a) a.begin(),a.end()

#define rall(a) a.rbegin(),a.rend()

#define rep(i,n) range(i,0,n)

#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)

#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)

#define INF ((int)1<<30)

#define EPS (1e-9)

#define MOD (1000000007ll)

#define fcout(a) cout<<setprecision(a)<<fixed

#define fs first

#define sc second

#define PI (3.1415926535897932384)



int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}

template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}

template<class S>S max(vector<S>&a){return *max_element(all(a));}

template<class S>S min(vector<S>&a){return *min_element(all(a));}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}



template<class T>void puta(T&&t){cout<<t<<"\n";}

template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}

void YN(bool b){tf(b,"YES","NO");}

void Yn(bool b){tf(b,"Yes","No");}

void yn(bool b){tf(b,"yes","no");}

template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};

template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}

template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}



/*他のライブラリを入れる場所*/

int popcnt(int x){return __builtin_popcount(x);}

int popcnt(ll x){return __builtin_popcountll(x);}

int bitdig(int x){return 32 - __builtin_clz(x);}

int bitdig(ll x){return 64 - __builtin_clzll(x);}

int bitffs(int x){return __builtin_ffs(x);}

int bitffs(ll x){return __builtin_ffsll(x);}



int main(){

	cin.tie(0);

	ios::sync_with_stdio(false);

	ll n;

	cin>>n;

	vl t(3),a(n);

	cin>>t>>a;



	vvl ans(3,vl(1<<n,0));

	rep(i,3){

		range(s,1,1<<n){

			ll tmp=0;

			rep(j,n)if(s&(1<<j))tmp+=a[j];

			ans[i][s]=abs(t[i]-tmp)+(popcnt(s)-1)*10;

		}

	}



	ll v=LINF;

	range(i,1,1<<n)range(j,1,1<<n)range(k,1,1<<n){

		if((i&j) or (j&k) or (k&i))continue;

		chmin(v,ans[0][i]+ans[1][j]+ans[2][k]);

	}

	puta(v);

	return 0;

}

// Fastest known solution for this problem: