from collections import Counter

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

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





def base_n(x, n, zero_padding=8):

    retval = [[], ['0']][x == 0]

    while x > 0:

        x, r = divmod(x, n)

        retval.append(str(r))

    cnt = zero_padding - len(retval)

    pad = ['', '0'*cnt][cnt > 0]

    return pad+''.join(retval[::-1])



ans = 10**8

for i in range(4**n):

    base_4 = base_n(i, 4, n)

    n_bamboo = n - base_4.count("0")

    ctr = Counter(base_4)

    if n_bamboo < 3 or any(k not in list(ctr.keys()) for k in "123"):

        continue



    cost = 0

    for x, y in zip([a, b, c], "123"):

        cost += abs(x - sum(L[idx]for idx, v in enumerate(base_4)

                            if v == y))+(ctr[y]-1)*10

    if ans > cost:

        ans = cost

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

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

INF = 10**8





def dfs(current_index, sum_a, sum_b, sum_c):

    if current_index == n:

        if min(sum_a, sum_b, sum_c) > 0:

            return sum(abs(x-y) for x, y in

                       zip([a, b, c], [sum_a, sum_b, sum_c]))-30

        else:

            return INF



    cost_none = dfs(current_index+1, sum_a, sum_b, sum_c)

    cost_a = dfs(current_index+1, sum_a+L[current_index], sum_b, sum_c)+10

    cost_b = dfs(current_index+1, sum_a, sum_b+L[current_index], sum_c)+10

    cost_c = dfs(current_index+1, sum_a, sum_b, sum_c+L[current_index])+10

    return min(cost_none, cost_a, cost_b, cost_c)



print((dfs(0, 0, 0, 0)))
from collections import Counter

n, a, b, c = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(n)]


def base_n(x, n, zero_padding=8):
    retval = [[], ["0"]][x == 0]
    while x > 0:
        x, r = divmod(x, n)
        retval.append(str(r))
    cnt = zero_padding - len(retval)
    pad = ["", "0" * cnt][cnt > 0]
    return pad + "".join(retval[::-1])


ans = 10**8
for i in range(4**n):
    base_4 = base_n(i, 4, n)
    n_bamboo = n - base_4.count("0")
    ctr = Counter(base_4)
    if n_bamboo < 3 or any(k not in list(ctr.keys()) for k in "123"):
        continue
    cost = 0
    for x, y in zip([a, b, c], "123"):
        cost += (
            abs(x - sum(L[idx] for idx, v in enumerate(base_4) if v == y))
            + (ctr[y] - 1) * 10
        )
    if ans > cost:
        ans = cost
print(ans)

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


def dfs(current_index, sum_a, sum_b, sum_c):
    if current_index == n:
        if min(sum_a, sum_b, sum_c) > 0:
            return (
                sum(abs(x - y) for x, y in zip([a, b, c], [sum_a, sum_b, sum_c])) - 30
            )
        else:
            return INF
    cost_none = dfs(current_index + 1, sum_a, sum_b, sum_c)
    cost_a = dfs(current_index + 1, sum_a + L[current_index], sum_b, sum_c) + 10
    cost_b = dfs(current_index + 1, sum_a, sum_b + L[current_index], sum_c) + 10
    cost_c = dfs(current_index + 1, sum_a, sum_b, sum_c + L[current_index]) + 10
    return min(cost_none, cost_a, cost_b, cost_c)


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

-from collections import Counter - +INF = 10**8 -def base_n(x, n, zero_padding=8): -    retval = [[], ["0"]][x == 0] -    while x > 0: -        x, r = divmod(x, n) -        retval.append(str(r)) -    cnt = zero_padding - len(retval) -    pad = ["", "0" * cnt][cnt > 0] -    return pad + "".join(retval[::-1]) +def dfs(current_index, sum_a, sum_b, sum_c): +    if current_index == n: +        if min(sum_a, sum_b, sum_c) > 0: +            return ( +                sum(abs(x - y) for x, y in zip([a, b, c], [sum_a, sum_b, sum_c])) - 30 +            ) +        else: +            return INF +    cost_none = dfs(current_index + 1, sum_a, sum_b, sum_c) +    cost_a = dfs(current_index + 1, sum_a + L[current_index], sum_b, sum_c) + 10 +    cost_b = dfs(current_index + 1, sum_a, sum_b + L[current_index], sum_c) + 10 +    cost_c = dfs(current_index + 1, sum_a, sum_b, sum_c + L[current_index]) + 10 +    return min(cost_none, cost_a, cost_b, cost_c) -ans = 10**8 -for i in range(4**n): -    base_4 = base_n(i, 4, n) -    n_bamboo = n - base_4.count("0") -    ctr = Counter(base_4) -    if n_bamboo < 3 or any(k not in list(ctr.keys()) for k in "123"): -        continue -    cost = 0 -    for x, y in zip([a, b, c], "123"): -        cost += ( -            abs(x - sum(L[idx] for idx, v in enumerate(base_4) if v == y)) -            + (ctr[y] - 1) * 10 -        ) -    if ans > cost: -        ans = cost -print(ans) +print((dfs(0, 0, 0, 0)))