#include<bits/stdc++.h>
using namespace std;
int n;
int l[10];
int req[5];
bool used[10];
bool choose[10];
vector<int> could;
int closest(int q){
	int *p=lower_bound(l+1,l+n+1,q);
	int l=*(p-1),r=*p;
	if(q-l<r-q){
		return l;
	}
	return r;
}
int closest2(int q){
	int *p=lower_bound(could.begin(),could.end(),q);
	int l=*(p-1),r=*p;
	if(q-l<r-q){
		return l;
	}
	return r;
}
int main()
{
	cin>>n>req[1]>>req[2]>>req[3];
	for(int i=1;i<=n;i++)
	   cin>>l[i];
	sort(l+1,l+n+1);
	int ans=0;
	int least[5];
	int leastid[5];
	memset(least,63,sizeof(least));
	memset(leastid,-1,sizeof(leastid));
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=3;j++){
			if(req[j]<l[i]){
				int exde=l[i]-req[j];
				if(abs(l[i]+closest(exde)-req[j])>=exde){
				    least[j]=min(least[j],exde);
					if(least[j]==exde)
					   leastid[j]=i;
				}
			}
		}
	}
	for(int i=1;i<=3;i++)
	   if(leastid[i]>0)
	      used[leastid[i]]=true;
	vector<int> free;
	for(int i=1;i<=n;i++)
	   if(!used[i])
	      free.push_back(i);
	while(!choose[0]){
		totsum=lastsum;
		for(int i=free.size()-1;i>=0;i--){
			if(choose[i]){
			    choose[i]=false;
				totsum-=free[i];
			}
			else{
				totsum+=free[i];
				choose[i]=true;
				break;
			}
		}
		if(choose[0])
		   break;
		could.push_back(totsum);
		lastsum=totsum;
	}
	for(int i=1;i<=3;i++){
		if(least[i]>n){
			least[i]=abs(req[i]-closest2(req[i]));
		}
	}
	cout<<least[1]+least[2]+least[3];
	return 0;
}
