import itertools
import numpy as np

N, A, B, C = map(int, input().split())

l = []
for i in range(N):
    num = int(input())
    l.append(num)
l = np.array(l)

min_loss = 9999999999999999
for pat in itertools.product(["A", "B", "C", "D"], repeat=N):
    if pat.count("A") > 0 and pat.count("B") > 0 and pat.count("C") > 0:
        # pat = np.array(pat)
        pat_A = l[[p == "A" for p in pat]]
        pat_B = l[[p == "B" for p in pat]]
        pat_C = l[[p == "C" for p in pat]]

        loss_A = abs(A-pat_A.sum())+10*(len(pat_A)-1)
        loss_B = abs(B-pat_B.sum())+10*(len(pat_B)-1)
        loss_C = abs(C-pat_C.sum())+10*(len(pat_C)-1)

        loss = loss_A+loss_B+loss_C
        min_loss = min(min_loss, loss)

print(min_loss)
