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

int n, A, B, C, l[10], ans;

void omgJaeyoung(int a, int b, int c, int idx, int cnt){
	if(idx == n){
		if(a == 0 || b == 0 || c == 0)	return;
		ans = min(ans, abs(A-a)+abs(B-b)+abs(C-c)+10*(cnt-3));
		return;
	}
	omgJaeyoung(a+l[idx], b, c, idx+1, cnt+1);
	omgJaeyoung(a, b+l[idx], c, idx+1, cnt+1);
	omgJaeyoung(a, b, c+l[idx], idx+1, cnt+1);
	omgJaeyoung(a, b, c, idx+1, cnt);
}

int main() {
	cin>>n>>A>>B>>C;
	for(int i = 0;i<n;i++)	cin>>l[i];
	ans = 987654321;
	omgJaeyoung(0, 0, 0, 0, 0);
	cout<<ans<<endl;
	return 0;
}