#include <bits/stdc++.h>
using namespace std;

int N,A,B,C;
vector<int> l(8);

int dfs(int k,int a,int b,int c){
	if(k==N){
		if(a>0 && b>0 && c>0) return abs(A-a)+abs(B-b)+abs(C-c)-30;
		else return 99999999;
	}
	int ans=dfs(k+1,a,b,c);
	ans=min(ans,dfs(k+1,a+l[k],b,c)+10);
	ans=min(ans,dfs(k+1,a,b+l[k],c)+10);
	ans=min(ans,dfs(k+1,a,b,c+l[k])+10);
	return ans;
}

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;
}