#include<cstdio>
#include<iostream>
#include<cstdlib>

using namespace std;
#define MAXN 5000000

int N,A,B,C,l[10]={},minn=MAXN,tmp;

void saiki(int n,int a,int b,int c,int count){
	if(n==0){
		if(a==0||b==0||c==0)return;
		tmp=abs(a-A)+abs(b-B)+abs(c-C)+(count-3)*10;
		minn=min(minn,tmp);
		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,0);

	cout<<minn<<"\n";

	return 0;
}
