#include <iostream>
#include <cmath>
using namespace std;
int n, a, b, c, l[9], ans=1e9;

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

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