#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
using namespace std;

int n,a,b,c;
int l[8];
int dfs(int m,int aa,int bb,int cc){
	if(m==8){
		if(min(aa,min(bb,cc))==0)
			return 99999999;
		return abs(a-aa)+abs(b-bb)+abs(c-cc)-30;
	}
	int ret0,ret1,ret2,ret3;
	ret0=dfs(m+1,aa,bb,cc);
	ret1=dfs(m+1,aa+l[m],bb,cc)+10;
	ret2=dfs(m+1,aa,bb+l[m],cc)+10;
	ret3=dfs(m+1,aa,bb,cc+l[m])+10;
	return min(min(min(ret0,ret1),ret2),ret3);
}


int main(){
	cin>>n>>a>>b>>c;
	for(int i=0;i<n;i++)
	{
		cin>>l[i];
	}
	cout<<dfs(0,0,0,0)<<endl;
	return 0;
}


	