from itertools import product
n, *A = map(int, input().split())
L = [int(input()) for _ in range(n)]
m_ = sum(abs(A[i]-L[i]) for i in range(3))
for P in product(range(4), repeat = n):
    C = [[] for _ in range(4)]
    m = 0
    for i in range(n):
        C[P[i]].append(L[i])
    C = C[1:]
    if [] in C: continue
    for i in range(3):
        m += (len(C[i])-1)*10+abs(sum(C[i])-A[i])
    m_ = min(m_, m)
print(m_)