N, A, B, C= map(int, input().split())
L = [int(input()) for _ in range(N)]

K = 4

minmp = 1e8
for x in range(123, pow(4, N)):
    v = x
    c = [0] * K
    s = [0] * K
    i = 0
    while v > 0:
        m = v % K
        c[m] += 1
        s[m] += L[i]
        i += 1
        v //= K

    if c[1] > 0 and c[2] > 0 and c[3] > 0:
        minmp = min(minmp, (c[1] + c[2] + c[3] - 3) * 10 + abs(s[1] - A) + abs(s[2] - B) + abs(s[3] - C))

print(minmp)