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

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

ABC=[A,B,C]



def base2n(Num,n):

    if Num<n:

        return str(Num)

    else:

        return base2n(Num//n,n)+str(Num%n)



ans=10**6

    

for i in range(4**N):

    i_4=("0"*N+base2n(i,4))[-N:]

    Group=[[] for i in range(4)]

    for j in range(N):

        Group[int(i_4[j])-1].append(l[j])

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

        ans=min(ans,(N-3-len(Group[3]))*10+sum([abs(ABC[j] - sum(Group[j])) for j in range(3)]))

        

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

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



inf=10**6

    

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

    else:

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

        ret1=dfs(cur+1,a+l[cur],b,c)+10

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

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

    return min(ret0,ret1,ret2,ret3)

print((dfs(0,0,0,0)))
N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(N)]
ABC = [A, B, C]


def base2n(Num, n):
    if Num < n:
        return str(Num)
    else:
        return base2n(Num // n, n) + str(Num % n)


ans = 10**6
for i in range(4**N):
    i_4 = ("0" * N + base2n(i, 4))[-N:]
    Group = [[] for i in range(4)]
    for j in range(N):
        Group[int(i_4[j]) - 1].append(l[j])
    if len(Group[0]) * len(Group[1]) * len(Group[2]) != 0:
        ans = min(
            ans,
            (N - 3 - len(Group[3])) * 10
            + sum([abs(ABC[j] - sum(Group[j])) for j in range(3)]),
        )
print(ans)

N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(N)]
inf = 10**6


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
    else:
        ret0 = dfs(cur + 1, a, b, c)
        ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
        ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
        ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


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

-ABC = [A, B, C] +inf = 10**6 -def base2n(Num, n): -    if Num < n: -        return str(Num) +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 -        return base2n(Num // n, n) + str(Num % n) +        ret0 = dfs(cur + 1, a, b, c) +        ret1 = dfs(cur + 1, a + l[cur], b, c) + 10 +        ret2 = dfs(cur + 1, a, b + l[cur], c) + 10 +        ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10 +    return min(ret0, ret1, ret2, ret3) -ans = 10**6 -for i in range(4**N): -    i_4 = ("0" * N + base2n(i, 4))[-N:] -    Group = [[] for i in range(4)] -    for j in range(N): -        Group[int(i_4[j]) - 1].append(l[j]) -    if len(Group[0]) * len(Group[1]) * len(Group[2]) != 0: -        ans = min( -            ans, -            (N - 3 - len(Group[3])) * 10 -            + sum([abs(ABC[j] - sum(Group[j])) for j in range(3)]), -        ) -print(ans) +print((dfs(0, 0, 0, 0)))