#include<iostream>
#include<cmath>
using namespace std;
#define INF 10e9
static const int MAX_N=8;
int T[MAX_N];
	int N,A,B,C;

int ans(int i,int a,int b,int c,int cost){
	if(i==N){
		if(a>0 && b>0 && c>0)
			return cost+abs(A-a)+abs(B-b)+abs(C-c);
		else
			return INF;
	}
	return min(min(ans(i+1,a,b,c,cost),ans(i+1,a+T[i],b,c,cost+(a>0?10:0))),min(ans(i+1,a,b+T[i],c,cost+(b>0?10:0)),ans(i+1,a,b,c+T[i],cost+(c>0?10:0))));
}
int main(void){
		cin >> N >> A >> B >> C;
	for(int i=0;i<N;i++)
		cin >> T[i];
	
	cout << ans(0,0,0,0,0) << endl;
	return 0;
}