N, A, B, C, *X = list(map(int, open(0).read().split()))



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

    if i == N:

        if a * b * c == 0:

            return 10 ** 9 + 7

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



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

    v1 = dfs(i + 1, a + X[i], b, c) + int(a > 0) * 10

    v2 = dfs(i + 1, a, b + X[i], c) + int(b > 0) * 10

    v3 = dfs(i + 1, a, b, c + X[i]) + int(c > 0) * 10



    return min(v0, v1, v2, v3)





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



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

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





def dfs(idx, a, b, c, cnt):

    if idx == N:

        if min(a, b, c) > 0:

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

        else:

            return 10 ** 9



    res = 10 ** 9

    res = min(res, dfs(idx + 1, a, b, c, cnt))

    res = min(res, dfs(idx + 1, a + X[idx], b, c, cnt + 10))

    res = min(res, dfs(idx + 1, a, b + X[idx], c, cnt + 10))

    res = min(res, dfs(idx + 1, a, b, c + X[idx], cnt + 10))

    return res





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

N, A, B, C, *X = list(map(int, open(0).read().split()))


def dfs(i, a, b, c):
    if i == N:
        if a * b * c == 0:
            return 10**9 + 7
        return abs(A - a) + abs(B - b) + abs(C - c)
    v0 = dfs(i + 1, a, b, c)
    v1 = dfs(i + 1, a + X[i], b, c) + int(a > 0) * 10
    v2 = dfs(i + 1, a, b + X[i], c) + int(b > 0) * 10
    v3 = dfs(i + 1, a, b, c + X[i]) + int(c > 0) * 10
    return min(v0, v1, v2, v3)


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

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


def dfs(idx, a, b, c, cnt):
    if idx == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) + cnt - 30
        else:
            return 10**9
    res = 10**9
    res = min(res, dfs(idx + 1, a, b, c, cnt))
    res = min(res, dfs(idx + 1, a + X[idx], b, c, cnt + 10))
    res = min(res, dfs(idx + 1, a, b + X[idx], c, cnt + 10))
    res = min(res, dfs(idx + 1, a, b, c + X[idx], cnt + 10))
    return res


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

-N, A, B, C, *X = list(map(int, open(0).read().split())) +N, A, B, C = list(map(int, input().split())) +X = [int(eval(input())) for _ in range(N)] -def dfs(i, a, b, c): -    if i == N: -        if a * b * c == 0: -            return 10**9 + 7 -        return abs(A - a) + abs(B - b) + abs(C - c) -    v0 = dfs(i + 1, a, b, c) -    v1 = dfs(i + 1, a + X[i], b, c) + int(a > 0) * 10 -    v2 = dfs(i + 1, a, b + X[i], c) + int(b > 0) * 10 -    v3 = dfs(i + 1, a, b, c + X[i]) + int(c > 0) * 10 -    return min(v0, v1, v2, v3) +def dfs(idx, a, b, c, cnt): +    if idx == N: +        if min(a, b, c) > 0: +            return abs(a - A) + abs(b - B) + abs(c - C) + cnt - 30 +        else: +            return 10**9 +    res = 10**9 +    res = min(res, dfs(idx + 1, a, b, c, cnt)) +    res = min(res, dfs(idx + 1, a + X[idx], b, c, cnt + 10)) +    res = min(res, dfs(idx + 1, a, b + X[idx], c, cnt + 10)) +    res = min(res, dfs(idx + 1, a, b, c + X[idx], cnt + 10)) +    return res -print((dfs(0, 0, 0, 0))) +print((dfs(0, 0, 0, 0, 0)))