def Base_10_to_n(X, n):

    if (int(X/n)):

        return Base_10_to_n(int(X/n), n)+str(X%n)

    return str(X%n)



n,a,b,c=list(map(int,input().split()))

L=[]

for _ in range(n):

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



ans=99999

for i in range(4**len(L)):

    i_4_list=list(Base_10_to_n(i, 4).zfill(len(L)))

    at,bt,ct=[],[],[]

    for num,i_4 in enumerate(i_4_list):

        if i_4=='0':

            at.append(L[num])

        elif i_4=='1':

            bt.append(L[num])

        elif i_4=='2':

            ct.append(L[num])

        else:

            continue

    if min(len(at),len(bt),len(ct))>0:

        al=0

        al+=(len(at)+len(bt)+len(ct)-3)*10

        al+=(abs(sum(at)-a)+abs(sum(bt)-b)+abs(sum(ct)-c))

        if al < ans:

            ans=al

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

L = []

for i in range(N):

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



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

    if n == N:

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

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

        else:

            return 10000

    root1=dfs(n+1,a+L[n],b,c)+10

    root2=dfs(n+1,a,b+L[n],c)+10

    root3=dfs(n+1,a,b,c+L[n])+10

    root4=dfs(n+1,a,b,c)

    return min(root1,root2,root3,root4)

    

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



def Base_10_to_n(X, n):
    if int(X / n):
        return Base_10_to_n(int(X / n), n) + str(X % n)
    return str(X % n)


n, a, b, c = list(map(int, input().split()))
L = []
for _ in range(n):
    L.append(int(eval(input())))
ans = 99999
for i in range(4 ** len(L)):
    i_4_list = list(Base_10_to_n(i, 4).zfill(len(L)))
    at, bt, ct = [], [], []
    for num, i_4 in enumerate(i_4_list):
        if i_4 == "0":
            at.append(L[num])
        elif i_4 == "1":
            bt.append(L[num])
        elif i_4 == "2":
            ct.append(L[num])
        else:
            continue
    if min(len(at), len(bt), len(ct)) > 0:
        al = 0
        al += (len(at) + len(bt) + len(ct) - 3) * 10
        al += abs(sum(at) - a) + abs(sum(bt) - b) + abs(sum(ct) - c)
        if al < ans:
            ans = al
print(ans)

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


def dfs(n, a, b, c):
    if n == N:
        if min(a, b, c) > 0:
            return abs(A - a) + abs(B - b) + abs(C - c) - 30
        else:
            return 10000
    root1 = dfs(n + 1, a + L[n], b, c) + 10
    root2 = dfs(n + 1, a, b + L[n], c) + 10
    root3 = dfs(n + 1, a, b, c + L[n]) + 10
    root4 = dfs(n + 1, a, b, c)
    return min(root1, root2, root3, root4)


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

-def Base_10_to_n(X, n): -    if int(X / n): -        return Base_10_to_n(int(X / n), n) + str(X % n) -    return str(X % n) +N, A, B, C = list(map(int, input().split())) +L = [] +for i in range(N): +    L.append(int(eval(input()))) -n, a, b, c = list(map(int, input().split())) -L = [] -for _ in range(n): -    L.append(int(eval(input()))) -ans = 99999 -for i in range(4 ** len(L)): -    i_4_list = list(Base_10_to_n(i, 4).zfill(len(L))) -    at, bt, ct = [], [], [] -    for num, i_4 in enumerate(i_4_list): -        if i_4 == "0": -            at.append(L[num]) -        elif i_4 == "1": -            bt.append(L[num]) -        elif i_4 == "2": -            ct.append(L[num]) +def dfs(n, a, b, c): +    if n == N: +        if min(a, b, c) > 0: +            return abs(A - a) + abs(B - b) + abs(C - c) - 30 -            continue -    if min(len(at), len(bt), len(ct)) > 0: -        al = 0 -        al += (len(at) + len(bt) + len(ct) - 3) * 10 -        al += abs(sum(at) - a) + abs(sum(bt) - b) + abs(sum(ct) - c) -        if al < ans: -            ans = al -print(ans) +            return 10000 +    root1 = dfs(n + 1, a + L[n], b, c) + 10 +    root2 = dfs(n + 1, a, b + L[n], c) + 10 +    root3 = dfs(n + 1, a, b, c + L[n]) + 10 +    root4 = dfs(n + 1, a, b, c) +    return min(root1, root2, root3, root4) + + +print((dfs(0, 0, 0, 0)))