import itertools



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

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



d=list(itertools.product([0,1,2,3], repeat=N))



MIN=10**10

for i in range(len(d)):

    ans=0

    a_num=0

    b_num=0

    c_num=0

    a_kadomatu=A

    b_kadomatu=B

    c_kadomatu=C

    if {0,1,2} <= set(d[i]):

        for g in range(len(d[i])):

            if d[i][g]==0:

                a_num+=1

                a_kadomatu-=l[g]

            elif d[i][g]==1:

                b_num+=1

                b_kadomatu-=l[g]

            elif d[i][g]==2:

                c_num+=1

                c_kadomatu-=l[g]

        ans=abs(a_kadomatu)+abs(b_kadomatu)+abs(c_kadomatu)+10*(a_num-1)+10*(b_num-1)+10*(c_num-1)

        MIN=min(MIN,ans)

print(MIN)
def dfs(ka, kb, kc, cnta, cntb, cntc, phase):

    global ans

    if phase == n:

        if 0 < cnta and 0 < cntb and 0 < cntc:

            ans = min(ans, abs(a-ka) + abs(b-kb) + abs(c-kc) + 10*(cnta+cntb+cntc-3))

        return

    dfs(ka+l[phase], kb, kc, cnta+1, cntb, cntc, phase+1)

    dfs(ka, kb+l[phase], kc, cnta, cntb+1, cntc, phase+1)

    dfs(ka, kb, kc+l[phase], cnta, cntb, cntc+1, phase+1)

    dfs(ka, kb, kc, cnta, cntb, cntc, phase+1)





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

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

ans = 10**9

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

print(ans)
import itertools

N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(N)]
d = list(itertools.product([0, 1, 2, 3], repeat=N))
MIN = 10**10
for i in range(len(d)):
    ans = 0
    a_num = 0
    b_num = 0
    c_num = 0
    a_kadomatu = A
    b_kadomatu = B
    c_kadomatu = C
    if {0, 1, 2} <= set(d[i]):
        for g in range(len(d[i])):
            if d[i][g] == 0:
                a_num += 1
                a_kadomatu -= l[g]
            elif d[i][g] == 1:
                b_num += 1
                b_kadomatu -= l[g]
            elif d[i][g] == 2:
                c_num += 1
                c_kadomatu -= l[g]
        ans = (
            abs(a_kadomatu)
            + abs(b_kadomatu)
            + abs(c_kadomatu)
            + 10 * (a_num - 1)
            + 10 * (b_num - 1)
            + 10 * (c_num - 1)
        )
        MIN = min(MIN, ans)
print(MIN)

def dfs(ka, kb, kc, cnta, cntb, cntc, phase):
    global ans
    if phase == n:
        if 0 < cnta and 0 < cntb and 0 < cntc:
            ans = min(
                ans,
                abs(a - ka) + abs(b - kb) + abs(c - kc) + 10 * (cnta + cntb + cntc - 3),
            )
        return
    dfs(ka + l[phase], kb, kc, cnta + 1, cntb, cntc, phase + 1)
    dfs(ka, kb + l[phase], kc, cnta, cntb + 1, cntc, phase + 1)
    dfs(ka, kb, kc + l[phase], cnta, cntb, cntc + 1, phase + 1)
    dfs(ka, kb, kc, cnta, cntb, cntc, phase + 1)


n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
ans = 10**9
dfs(0, 0, 0, 0, 0, 0, 0)
print(ans)

-import itertools +def dfs(ka, kb, kc, cnta, cntb, cntc, phase): +    global ans +    if phase == n: +        if 0 < cnta and 0 < cntb and 0 < cntc: +            ans = min( +                ans, +                abs(a - ka) + abs(b - kb) + abs(c - kc) + 10 * (cnta + cntb + cntc - 3), +            ) +        return +    dfs(ka + l[phase], kb, kc, cnta + 1, cntb, cntc, phase + 1) +    dfs(ka, kb + l[phase], kc, cnta, cntb + 1, cntc, phase + 1) +    dfs(ka, kb, kc + l[phase], cnta, cntb, cntc + 1, phase + 1) +    dfs(ka, kb, kc, cnta, cntb, cntc, phase + 1) -N, A, B, C = list(map(int, input().split())) -l = [int(eval(input())) for _ in range(N)] -d = list(itertools.product([0, 1, 2, 3], repeat=N)) -MIN = 10**10 -for i in range(len(d)): -    ans = 0 -    a_num = 0 -    b_num = 0 -    c_num = 0 -    a_kadomatu = A -    b_kadomatu = B -    c_kadomatu = C -    if {0, 1, 2} <= set(d[i]): -        for g in range(len(d[i])): -            if d[i][g] == 0: -                a_num += 1 -                a_kadomatu -= l[g] -            elif d[i][g] == 1: -                b_num += 1 -                b_kadomatu -= l[g] -            elif d[i][g] == 2: -                c_num += 1 -                c_kadomatu -= l[g] -        ans = ( -            abs(a_kadomatu) -            + abs(b_kadomatu) -            + abs(c_kadomatu) -            + 10 * (a_num - 1) -            + 10 * (b_num - 1) -            + 10 * (c_num - 1) -        ) -        MIN = min(MIN, ans) -print(MIN) + +n, a, b, c = list(map(int, input().split())) +l = [int(eval(input())) for _ in range(n)] +ans = 10**9 +dfs(0, 0, 0, 0, 0, 0, 0) +print(ans)