from itertools import product


N, A, B, C = map(int, input().split())
l = []
for i in range(N):
    l.append(int(input()))
ans = min(sum(
    abs(sum(x for k, x in zip(p, 1) if k == r)-y) + 10 *(p.count(r) - 1)
    for r, y in enumerate((A, B, C), 1)
    )
    for p in product(range(4), repeat=N)
    if {1, 2, 3} <= set(p)
)
print(ans)