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

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

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

  if d == N:

    res = abs(a - A) + abs(b - B) + abs(c - C) - 30

    return 1e9 if min(a, b, c) == 0 else res

  ret = [0] * 4

  ret[0] = dfs(d + 1, a, b, c)

  ret[1] = dfs(d + 1, a + l[d], b, c) + 10

  ret[2] = dfs(d + 1, a, b + l[d], c) + 10

  ret[3] = dfs(d + 1, a, b, c + l[d]) + 10

  return min(ret)

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

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

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

def rec(itr, a, b, c, mp):

    if itr == N:

        if a == 0 or b == 0 or c == 0:

            return 10 ** 9

        return abs(a - A) + abs(b - B) + abs(c - C) + mp - 30

    res = rec(itr + 1, a, b, c, mp)

    res = min(res, rec(itr + 1, a + L[itr], b, c, mp) + 10)

    res = min(res, rec(itr + 1, a, b + L[itr], c, mp) + 10)

    res = min(res, rec(itr + 1, a, b, c + L[itr], mp) + 10)

    return res

print((rec(0, 0, 0, 0, 0)))

N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for i in range(N)]


def dfs(d, a, b, c):
    if d == N:
        res = abs(a - A) + abs(b - B) + abs(c - C) - 30
        return 1e9 if min(a, b, c) == 0 else res
    ret = [0] * 4
    ret[0] = dfs(d + 1, a, b, c)
    ret[1] = dfs(d + 1, a + l[d], b, c) + 10
    ret[2] = dfs(d + 1, a, b + l[d], c) + 10
    ret[3] = dfs(d + 1, a, b, c + l[d]) + 10
    return min(ret)


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

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


def rec(itr, a, b, c, mp):
    if itr == N:
        if a == 0 or b == 0 or c == 0:
            return 10**9
        return abs(a - A) + abs(b - B) + abs(c - C) + mp - 30
    res = rec(itr + 1, a, b, c, mp)
    res = min(res, rec(itr + 1, a + L[itr], b, c, mp) + 10)
    res = min(res, rec(itr + 1, a, b + L[itr], c, mp) + 10)
    res = min(res, rec(itr + 1, a, b, c + L[itr], mp) + 10)
    return res


print((rec(0, 0, 0, 0, 0)))

-l = [int(eval(input())) for i in range(N)] +L = [int(eval(input())) for _ in range(N)] -def dfs(d, a, b, c): -    if d == N: -        res = abs(a - A) + abs(b - B) + abs(c - C) - 30 -        return 1e9 if min(a, b, c) == 0 else res -    ret = [0] * 4 -    ret[0] = dfs(d + 1, a, b, c) -    ret[1] = dfs(d + 1, a + l[d], b, c) + 10 -    ret[2] = dfs(d + 1, a, b + l[d], c) + 10 -    ret[3] = dfs(d + 1, a, b, c + l[d]) + 10 -    return min(ret) +def rec(itr, a, b, c, mp): +    if itr == N: +        if a == 0 or b == 0 or c == 0: +            return 10**9 +        return abs(a - A) + abs(b - B) + abs(c - C) + mp - 30 +    res = rec(itr + 1, a, b, c, mp) +    res = min(res, rec(itr + 1, a + L[itr], b, c, mp) + 10) +    res = min(res, rec(itr + 1, a, b + L[itr], c, mp) + 10) +    res = min(res, rec(itr + 1, a, b, c + L[itr], mp) + 10) +    return res -print((dfs(0, 0, 0, 0))) +print((rec(0, 0, 0, 0, 0)))