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

int n,a,b,c,l[10],ans=2e9;

void dfs(int i, int x, int y, int z, int combo){
	if(i > n){
		if(x&&y&&z){
			ans = min(ans,abs(x-a)+abs(y-b)+abs(z-c)+combo*10);
		}
		return;
	}
	dfs(i+1,x+l[i],y,z,combo+1);
	dfs(i+1,x,y+l[i],z,combo+1);
	dfs(i+1,x,y,z+l[i],combo+1);
	dfs(i+1,x,y,z,combo);
}


int main()
{
	cin >> n >> a >> b >> c;
	for(int i = 1; i <= n; i++) cin >> l[i];
	dfs(1,0,0,0,-3);
	cout << ans << endl;
	return 0;
}