# coding: utf-8

def Base_10_to_n(X, n):

    X_dumy = X

    out = ''

    while X_dumy>0:

        out = str(X_dumy%n)+out

        X_dumy = int(X_dumy/n)

    return out

    

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

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

ans = float("inf")

for i in range(4**N):

    bits = Base_10_to_n(i, 4).zfill(N)

    a, b, c = 0, 0, 0

    cost = 0

    for j in range(len(bits)):

        if bits[j] == "0":

            pass

        elif bits[j] == "1":

            a += L[j]

            cost += 10

        elif bits[j] == "2":

            b += L[j]

            cost += 10

        else:

            c += L[j]

            cost += 10

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

        ans = min(ans, cost + abs(a-A)+abs(b-B)+abs(c-C) - 10*3)

print(ans)
# coding: utf-8

import sys

sys.setrecursionlimit(10**9)

def Base_10_to_n(X, n):

    X_dumy = X

    out = ''

    while X_dumy>0:

        out = str(X_dumy%n)+out

        X_dumy = int(X_dumy/n)

    return out

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

L = []

for i in range(N):

    L.append(int(eval(input())))

# L.sort()

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

    if cnt == N:

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

    r0 = dfs(cnt+1, a, b, c)

    r1 = dfs(cnt+1, a+L[cnt], b, c) + 10

    r2 = dfs(cnt+1, a, b+L[cnt], c) + 10

    r3 = dfs(cnt+1, a, b, c+L[cnt]) + 10

    return min(r0, r1, r2, r3)

    

print((dfs(0,0,0,0)))
# coding: utf-8
def Base_10_to_n(X, n):
    X_dumy = X
    out = ""
    while X_dumy > 0:
        out = str(X_dumy % n) + out
        X_dumy = int(X_dumy / n)
    return out


N, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(N)]
ans = float("inf")
for i in range(4**N):
    bits = Base_10_to_n(i, 4).zfill(N)
    a, b, c = 0, 0, 0
    cost = 0
    for j in range(len(bits)):
        if bits[j] == "0":
            pass
        elif bits[j] == "1":
            a += L[j]
            cost += 10
        elif bits[j] == "2":
            b += L[j]
            cost += 10
        else:
            c += L[j]
            cost += 10
    if min(a, b, c) > 0:
        ans = min(ans, cost + abs(a - A) + abs(b - B) + abs(c - C) - 10 * 3)
print(ans)

# coding: utf-8
import sys

sys.setrecursionlimit(10**9)


def Base_10_to_n(X, n):
    X_dumy = X
    out = ""
    while X_dumy > 0:
        out = str(X_dumy % n) + out
        X_dumy = int(X_dumy / n)
    return out


N, A, B, C = list(map(int, input().split()))
L = []
for i in range(N):
    L.append(int(eval(input())))
# L.sort()
def dfs(cnt, a, b, c):
    if cnt == N:
        return (
            abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else 10**9
        )
    r0 = dfs(cnt + 1, a, b, c)
    r1 = dfs(cnt + 1, a + L[cnt], b, c) + 10
    r2 = dfs(cnt + 1, a, b + L[cnt], c) + 10
    r3 = dfs(cnt + 1, a, b, c + L[cnt]) + 10
    return min(r0, r1, r2, r3)


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

+import sys + +sys.setrecursionlimit(10**9) + + -L = [int(eval(input())) for _ in range(N)] -ans = float("inf") -for i in range(4**N): -    bits = Base_10_to_n(i, 4).zfill(N) -    a, b, c = 0, 0, 0 -    cost = 0 -    for j in range(len(bits)): -        if bits[j] == "0": -            pass -        elif bits[j] == "1": -            a += L[j] -            cost += 10 -        elif bits[j] == "2": -            b += L[j] -            cost += 10 -        else: -            c += L[j] -            cost += 10 -    if min(a, b, c) > 0: -        ans = min(ans, cost + abs(a - A) + abs(b - B) + abs(c - C) - 10 * 3) -print(ans) +L = [] +for i in range(N): +    L.append(int(eval(input()))) +# L.sort() +def dfs(cnt, a, b, c): +    if cnt == N: +        return ( +            abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else 10**9 +        ) +    r0 = dfs(cnt + 1, a, b, c) +    r1 = dfs(cnt + 1, a + L[cnt], b, c) + 10 +    r2 = dfs(cnt + 1, a, b + L[cnt], c) + 10 +    r3 = dfs(cnt + 1, a, b, c + L[cnt]) + 10 +    return min(r0, r1, r2, r3) + + +print((dfs(0, 0, 0, 0)))