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

l = []

for _ in range(n):

    l.append(int(eval(input())))



def dfs(depth, t, ans):

    if depth == n:

        sum = calc(t)

        if sum < ans:

            return sum

        else:

            return ans



    for j in range(4):

        tt = t.copy()

        tt.append(j)

        ans = dfs(depth + 1, tt, ans)



    return ans



def calc(t):

    ttt = [ [0, 0] ] * 3



    for i, v in enumerate(t):

        if v < 3:

            ttt[v] = [ttt[v][0] + 1, ttt[v][1] + l[i]]



    if ttt[0][0] == 0 or ttt[1][0] == 0 or ttt[2][0] == 0:

        return 1000000000



    sum = 0

    abc = [a, b, c, 0]

    for i, v in enumerate(ttt):

        sum += ((v[0] - 1) * 10) + abs(v[1] - abc[i])



    return sum





ans = dfs(0, [], 1000000000)

print(ans)
N, A, B, C = list(map(int, input().split()))

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

INF = 10**12



def dfs(depth, a, b, c):

    if depth == N:

        return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else INF



    res1 = dfs(depth + 1, a, b, c)

    res2 = dfs(depth + 1, a + l[depth], b, c) + 10

    res3 = dfs(depth + 1, a, b + l[depth], c) + 10

    res4 = dfs(depth + 1, a, b, c + l[depth]) + 10



    return min(res1, res2, res3, res4)



print((dfs(0, 0, 0, 0)))
n, a, b, c = list(map(int, input().split()))
l = []
for _ in range(n):
    l.append(int(eval(input())))


def dfs(depth, t, ans):
    if depth == n:
        sum = calc(t)
        if sum < ans:
            return sum
        else:
            return ans
    for j in range(4):
        tt = t.copy()
        tt.append(j)
        ans = dfs(depth + 1, tt, ans)
    return ans


def calc(t):
    ttt = [[0, 0]] * 3
    for i, v in enumerate(t):
        if v < 3:
            ttt[v] = [ttt[v][0] + 1, ttt[v][1] + l[i]]
    if ttt[0][0] == 0 or ttt[1][0] == 0 or ttt[2][0] == 0:
        return 1000000000
    sum = 0
    abc = [a, b, c, 0]
    for i, v in enumerate(ttt):
        sum += ((v[0] - 1) * 10) + abs(v[1] - abc[i])
    return sum


ans = dfs(0, [], 1000000000)
print(ans)

N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(N)]
INF = 10**12


def dfs(depth, a, b, c):
    if depth == N:
        return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else INF
    res1 = dfs(depth + 1, a, b, c)
    res2 = dfs(depth + 1, a + l[depth], b, c) + 10
    res3 = dfs(depth + 1, a, b + l[depth], c) + 10
    res4 = dfs(depth + 1, a, b, c + l[depth]) + 10
    return min(res1, res2, res3, res4)


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

-n, a, b, c = list(map(int, input().split())) -l = [] -for _ in range(n): -    l.append(int(eval(input()))) +N, A, B, C = list(map(int, input().split())) +l = [int(eval(input())) for _ in range(N)] +INF = 10**12 -def dfs(depth, t, ans): -    if depth == n: -        sum = calc(t) -        if sum < ans: -            return sum -        else: -            return ans -    for j in range(4): -        tt = t.copy() -        tt.append(j) -        ans = dfs(depth + 1, tt, ans) -    return ans +def dfs(depth, a, b, c): +    if depth == N: +        return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else INF +    res1 = dfs(depth + 1, a, b, c) +    res2 = dfs(depth + 1, a + l[depth], b, c) + 10 +    res3 = dfs(depth + 1, a, b + l[depth], c) + 10 +    res4 = dfs(depth + 1, a, b, c + l[depth]) + 10 +    return min(res1, res2, res3, res4) -def calc(t): -    ttt = [[0, 0]] * 3 -    for i, v in enumerate(t): -        if v < 3: -            ttt[v] = [ttt[v][0] + 1, ttt[v][1] + l[i]] -    if ttt[0][0] == 0 or ttt[1][0] == 0 or ttt[2][0] == 0: -        return 1000000000 -    sum = 0 -    abc = [a, b, c, 0] -    for i, v in enumerate(ttt): -        sum += ((v[0] - 1) * 10) + abs(v[1] - abc[i]) -    return sum - - -ans = dfs(0, [], 1000000000) -print(ans) +print((dfs(0, 0, 0, 0)))