n,a,b,c=map(int,input().split())
l=[]
for i in range(n):
	l.append(int(input()))
def f(x):
	d=""
	while x!=0:
		d+=str(x%4)
		x//=4
	return d[::-1]
ans=[]
for i in range(4**n):
	A=0
	B=0
	C=0
	aa=0
	cost=0
	ff=str(f(i))
	for j in range(len(ff)):
		if ff[j]=="1":
			A+=l[j]
			aa+=1
		elif ff[j]=="2":
			B+=l[j]
			aa+=1
		elif ff[j]=="3":
			C+=l[j]
			aa+=1
	if A!=0 and B!=0 and C!=0:
		cost+=(aa-3)*10
		cost+=abs(A-a)+abs(B-b)+abs(C-c)
		ans.append(cost)
print(min(ans))








