n, a, b, c = list(map(int, input().split()))

l = [int(eval(input())) for _ in range(n)]



ans = 3000

for bits in range(4**n):

    xa = xb = xc = 0

    tmp_ans = 0

    for i in range(n):

        f = (bits//(4**i)) % 4

        if f == 1:

            if xa != 0:

                tmp_ans += 10

            xa += l[i]

        elif f == 2:

            if xb != 0:

                tmp_ans += 10

            xb += l[i]

        elif f == 3:

            if xc != 0:

                tmp_ans += 10

            xc += l[i]



    if xa == 0 or xb == 0 or xc == 0:

        continue

    

    tmp_ans += abs(a - xa) + abs(b - xb) + abs(c - xc)

    ans = min(ans, tmp_ans)



print(ans)

n, a, b, c = list(map(int, input().split()))

l = [int(eval(input())) for _ in range(n)]

INF = 10**9



def dfs(index, x, y, z):

    if index == n:

        return abs(a-x) + abs(b-y) + abs(c-z) - 30 if min(x, y, z) > 0 else INF



    cand1 = dfs(index+1, x+l[index], y, z) + 10

    cand2 = dfs(index+1, x, y+l[index], z) + 10

    cand3 = dfs(index+1, x, y, z+l[index]) + 10

    cand4 = dfs(index+1, x, y, z)



    return min(cand1, cand2, cand3, cand4)



print((dfs(0, 0, 0, 0)))

n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
ans = 3000
for bits in range(4**n):
    xa = xb = xc = 0
    tmp_ans = 0
    for i in range(n):
        f = (bits // (4**i)) % 4
        if f == 1:
            if xa != 0:
                tmp_ans += 10
            xa += l[i]
        elif f == 2:
            if xb != 0:
                tmp_ans += 10
            xb += l[i]
        elif f == 3:
            if xc != 0:
                tmp_ans += 10
            xc += l[i]
    if xa == 0 or xb == 0 or xc == 0:
        continue
    tmp_ans += abs(a - xa) + abs(b - xb) + abs(c - xc)
    ans = min(ans, tmp_ans)
print(ans)

n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
INF = 10**9


def dfs(index, x, y, z):
    if index == n:
        return abs(a - x) + abs(b - y) + abs(c - z) - 30 if min(x, y, z) > 0 else INF
    cand1 = dfs(index + 1, x + l[index], y, z) + 10
    cand2 = dfs(index + 1, x, y + l[index], z) + 10
    cand3 = dfs(index + 1, x, y, z + l[index]) + 10
    cand4 = dfs(index + 1, x, y, z)
    return min(cand1, cand2, cand3, cand4)


print((dfs(0, 0, 0, 0)))

-ans = 3000 -for bits in range(4**n): -    xa = xb = xc = 0 -    tmp_ans = 0 -    for i in range(n): -        f = (bits // (4**i)) % 4 -        if f == 1: -            if xa != 0: -                tmp_ans += 10 -            xa += l[i] -        elif f == 2: -            if xb != 0: -                tmp_ans += 10 -            xb += l[i] -        elif f == 3: -            if xc != 0: -                tmp_ans += 10 -            xc += l[i] -    if xa == 0 or xb == 0 or xc == 0: -        continue -    tmp_ans += abs(a - xa) + abs(b - xb) + abs(c - xc) -    ans = min(ans, tmp_ans) -print(ans) +INF = 10**9 + + +def dfs(index, x, y, z): +    if index == n: +        return abs(a - x) + abs(b - y) + abs(c - z) - 30 if min(x, y, z) > 0 else INF +    cand1 = dfs(index + 1, x + l[index], y, z) + 10 +    cand2 = dfs(index + 1, x, y + l[index], z) + 10 +    cand3 = dfs(index + 1, x, y, z + l[index]) + 10 +    cand4 = dfs(index + 1, x, y, z) +    return min(cand1, cand2, cand3, cand4) + + +print((dfs(0, 0, 0, 0)))