# ABC119C

# Synthetic Kadomatsu

Enter = list(map(int, input().split()))

N = Enter[0]

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



ans = 10 ** 10



# 4 bist search

for i in range(4**N):

    mask = i

    NowCost = 0

    Group = [[] * 4 for _ in range(4)]

    for j in range(N-1, -1, -1):

        Group[mask%4].append(L[j])

        mask //= 4

    if len(Group[0]) == 0 or len(Group[1]) == 0 or len(Group[2]) == 0:

        continue

    for j in range(3):

        NowCost += 10 * (len(Group[j]) - 1)

        NowCost += abs(sum(Group[j]) - Enter[j+1])

    ans = min(ans, NowCost)

print(ans)

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

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



INF = 10 ** 9



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

    if cur == N:

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

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

        else:

            return INF

    ret1 = dfs(cur+1, a, b, c)

    ret2 = dfs(cur+1, a+L[cur], b, c) + 10

    ret3 = dfs(cur+1, a, b+L[cur], c) + 10

    ret4 = dfs(cur+1, a, b, c+L[cur]) + 10

    return min(ret1, ret2, ret3, ret4)



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

# ABC119C
# Synthetic Kadomatsu
Enter = list(map(int, input().split()))
N = Enter[0]
L = [int(eval(input())) for _ in range(N)]
ans = 10**10
# 4 bist search
for i in range(4**N):
    mask = i
    NowCost = 0
    Group = [[] * 4 for _ in range(4)]
    for j in range(N - 1, -1, -1):
        Group[mask % 4].append(L[j])
        mask //= 4
    if len(Group[0]) == 0 or len(Group[1]) == 0 or len(Group[2]) == 0:
        continue
    for j in range(3):
        NowCost += 10 * (len(Group[j]) - 1)
        NowCost += abs(sum(Group[j]) - Enter[j + 1])
    ans = min(ans, NowCost)
print(ans)

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


def dfs(cur, a, b, c):
    if cur == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
        else:
            return INF
    ret1 = dfs(cur + 1, a, b, c)
    ret2 = dfs(cur + 1, a + L[cur], b, c) + 10
    ret3 = dfs(cur + 1, a, b + L[cur], c) + 10
    ret4 = dfs(cur + 1, a, b, c + L[cur]) + 10
    return min(ret1, ret2, ret3, ret4)


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

-# ABC119C -# Synthetic Kadomatsu -Enter = list(map(int, input().split())) -N = Enter[0] +N, A, B, C = list(map(int, input().split())) -ans = 10**10 -# 4 bist search -for i in range(4**N): -    mask = i -    NowCost = 0 -    Group = [[] * 4 for _ in range(4)] -    for j in range(N - 1, -1, -1): -        Group[mask % 4].append(L[j]) -        mask //= 4 -    if len(Group[0]) == 0 or len(Group[1]) == 0 or len(Group[2]) == 0: -        continue -    for j in range(3): -        NowCost += 10 * (len(Group[j]) - 1) -        NowCost += abs(sum(Group[j]) - Enter[j + 1]) -    ans = min(ans, NowCost) -print(ans) +INF = 10**9 + + +def dfs(cur, a, b, c): +    if cur == N: +        if min(a, b, c) > 0: +            return abs(a - A) + abs(b - B) + abs(c - C) - 30 +        else: +            return INF +    ret1 = dfs(cur + 1, a, b, c) +    ret2 = dfs(cur + 1, a + L[cur], b, c) + 10 +    ret3 = dfs(cur + 1, a, b + L[cur], c) + 10 +    ret4 = dfs(cur + 1, a, b, c + L[cur]) + 10 +    return min(ret1, ret2, ret3, ret4) + + +print((dfs(0, 0, 0, 0)))