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

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

inf = 10 ** 18





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

    if i == n:

        if a < 1 or b < 1 or c < 1:

            return inf

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

    res = dfs(i + 1, a, b, c)

    res = min([res, dfs(i + 1, a + l[i], b, c) + (10 if a > 0 else 0)])

    res = min([res, dfs(i + 1, a, b + l[i], c) + (10 if b > 0 else 0)])

    res = min([res, dfs(i + 1, a, b, c + l[i]) + (10 if c > 0 else 0)])

    return res





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

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

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





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

    if n == i:

        if a < 1 or b < 1 or c < 1:

            return 10 ** 18

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



    res = dfs(i + 1, a, b, c)

    res = min([res, dfs(i + 1, a + l[i], b, c) + (10 if a > 0 else 0)])

    res = min([res, dfs(i + 1, a, b + l[i], c) + (10 if b > 0 else 0)])

    res = min([res, dfs(i + 1, a, b, c + l[i]) + (10 if c > 0 else 0)])

    return res





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

n, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
inf = 10**18


def dfs(i, a, b, c):
    if i == n:
        if a < 1 or b < 1 or c < 1:
            return inf
        return abs(A - a) + abs(B - b) + abs(C - c)
    res = dfs(i + 1, a, b, c)
    res = min([res, dfs(i + 1, a + l[i], b, c) + (10 if a > 0 else 0)])
    res = min([res, dfs(i + 1, a, b + l[i], c) + (10 if b > 0 else 0)])
    res = min([res, dfs(i + 1, a, b, c + l[i]) + (10 if c > 0 else 0)])
    return res


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

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


def dfs(i, a, b, c):
    if n == i:
        if a < 1 or b < 1 or c < 1:
            return 10**18
        return abs(A - a) + abs(B - b) + abs(C - c)
    res = dfs(i + 1, a, b, c)
    res = min([res, dfs(i + 1, a + l[i], b, c) + (10 if a > 0 else 0)])
    res = min([res, dfs(i + 1, a, b + l[i], c) + (10 if b > 0 else 0)])
    res = min([res, dfs(i + 1, a, b, c + l[i]) + (10 if c > 0 else 0)])
    return res


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

-inf = 10**18 -    if i == n: +    if n == i: -            return inf +            return 10**18