#include <bits/stdc++.h>
using namespace std;
long long l[8];
int N,A,B,C;
const int INF = 1e9+7;
int dfs(int num,int a,int b,int c,int sum){
	if(num==N){
		if(a==0||b==0||c==0)return INF;
		else return abs(A-a)+abs(B-b)+abs(C-c)+sum*10 - 30;
	}
	int cost1=dfs(num+1,a+l[num],b,c,sum+1);
	int cost2=dfs(num+1,a,b+l[num],c,sum+1);
	int cost3=dfs(num+1,a,b,c+l[num],sum+1);
	int cost4=dfs(num+1,a,b,c,sum);
		return min({cost1,cost2,cost3,cost4});
}

int main(void){
	
	cin >> N >> A >> B >> C;
	for(int i=0;i<N;i++)cin >> l[i];
	cout << dfs(0,0,0,0,0) << endl;
}