#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<numeric>

using namespace std;

#define INF 100000;

int n,A,B,C,l[10],ct=0,ans=100000;

void saiki(int n,int a,int b,int c,int count){
	if(n==0){
		if(a==0||b==0||c==0){
			return;
		}
		ans=min(ans,(count-3)*10+abs(a-A)+abs(b-B)+abs(c-C));
		return;
	}
	saiki(n-1,a,b,c,count);
	saiki(n-1,a+l[n-1],b,c,count+1);
	saiki(n-1,a,b+l[n-1],c,count+1);
	saiki(n-1,a,b,c+l[n-1],count+1);


}

int main(void){

	cin>>n>>A>>B>>C;
	for (int i = 0; i < n; i++) {
		cin>>l[i];
	}

	saiki(n,0,0,0,ct);
	cout<<ans<<"\n";

	return 0;
}
