#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int n;
int A,B,C;
int L[10];
int cou;
int select[8];
int eachsum[8];
int subans;
int ans;
int asize;
int num[4];
vector<int> array;
void saiki(int now)
{
	if(now==n)
	{
		rep(i,4)
		{
			eachsum[i]=0;
			num[i]=0;
		}
		rep(i,n)
		{
			eachsum[select[i]]+=L[i];
			num[select[i]]++;
		}
		rep(i,3)
		{
			if(num[i]==0)break;
			if(i==2)
			{
				subans=10*(num[0]+num[1]+num[2]-3);
				subans+=abs(eachsum[0]-A);
				subans+=abs(eachsum[1]-B);
				subans+=abs(eachsum[2]-C);
				if(ans==-1||ans>subans)ans=subans;
			}
		}
		
	}
	else
	{
		rep(i,4)
		{
			select[now]=i;
			saiki(now+1);
		}
	}
}
int main()
{
	ans=-1;
	cin>>n;
	cin>>A>>B>>C;
	rep(i,n)
	{
		cin>>L[i];
	}
	saiki(0);
	cout<<ans<<endl;
	return 0;
}