import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, A, B, C = MAP()
L = [INT() for _ in range(N)]

#print(L)

mp = 0
for i in [C, B, A]:
	same = False
	for l in L:
		if l==i:
			L.remove(l)
			same = True
	if same:
		continue
	elif min(L) >= i:
		#print('min',i,min(L)-i)
		mp += min(L)-i
		L.remove(min(L))
	elif max(L) <= i and i - max(L) <= 10:
		#print('max',i,i-max(L))
		mp += i-max(L)
		L.remove(max(L))
	else:
		dif = float('INF')
		dif_idx = []
		for j in range(2**len(L)):
			tmp = []
			for k in range(len(L)):
				if (j>>k & 1):
					tmp.append(len(L)-k-1)
			tmpsum = sum([L[t] for t in tmp])
			if abs(i-tmpsum)<dif:
				dif = abs(i-tmpsum)
				dif_idx=tmp
		#print(dif_idx, [L[t] for t in dif_idx])
		#print('dif',dif_idx, [L[t] for t in dif_idx],abs(sum([L[t] for t in dif_idx])-i))
		mp += abs(sum([L[t] for t in dif_idx])-i) + (len(dif_idx)-1)*10
		for t in dif_idx:
			L.pop(t)

print(mp)
#print(L)