

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

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

#print("---", bamboos)

ans = float("inf")

def solve(lst, idx):

    global ans

    if idx == N:

        #print("qqqqq")

        for i in range(3):

            if len(lst[i]) == 0:

                return



        

        pa = 10 * (len(lst[0])-1) + abs(A - sum(lst[0]))

        pb = 10 * (len(lst[1])-1) + abs(B - sum(lst[1]))

        pc = 10 * (len(lst[2])-1) + abs(C - sum(lst[2]))

        #print(pa, pb, pc, lst)

        ans = min(ans, pa + pb + pc)

        #print("aaaaaaa")

        return



    

    for i in range(4):

        nxt_lst = [lst[0][:], lst[1][:], lst[2][:], lst[3][:]]

        nxt_lst[i].append(bamboos[idx])

        #print(lst, nxt_lst)

        

        solve(nxt_lst, idx+1)



empty_lst =  [[], [], [], []]   

solve(empty_lst, 0)

print(ans)


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

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

#print("---", bamboos)

INF = float("inf")

ans = INF

def solve(idx, cnt_merge, a, b, c):



    if idx == N:

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

            return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt_merge-3)

        else:

            return INF



    pa = solve(idx+1, cnt_merge+1, a+bamboos[idx], b, c)

    pb = solve(idx+1, cnt_merge+1, a, b+bamboos[idx], c)

    pc = solve(idx+1, cnt_merge+1, a, b, c+bamboos[idx])

    pn = solve(idx+1, cnt_merge, a, b, c)

    return min(pa, pb, pc, pn)





print((solve(0,0,0,0,0)))
N, A, B, C = list(map(int, input().split()))
bamboos = [int(eval(input())) for _ in range(N)]
# print("---", bamboos)
ans = float("inf")


def solve(lst, idx):
    global ans
    if idx == N:
        # print("qqqqq")
        for i in range(3):
            if len(lst[i]) == 0:
                return
        pa = 10 * (len(lst[0]) - 1) + abs(A - sum(lst[0]))
        pb = 10 * (len(lst[1]) - 1) + abs(B - sum(lst[1]))
        pc = 10 * (len(lst[2]) - 1) + abs(C - sum(lst[2]))
        # print(pa, pb, pc, lst)
        ans = min(ans, pa + pb + pc)
        # print("aaaaaaa")
        return
    for i in range(4):
        nxt_lst = [lst[0][:], lst[1][:], lst[2][:], lst[3][:]]
        nxt_lst[i].append(bamboos[idx])
        # print(lst, nxt_lst)
        solve(nxt_lst, idx + 1)


empty_lst = [[], [], [], []]
solve(empty_lst, 0)
print(ans)

N, A, B, C = list(map(int, input().split()))
bamboos = [int(eval(input())) for _ in range(N)]
# print("---", bamboos)
INF = float("inf")
ans = INF


def solve(idx, cnt_merge, a, b, c):
    if idx == N:
        if min(a, b, c) > 0:
            return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt_merge - 3)
        else:
            return INF
    pa = solve(idx + 1, cnt_merge + 1, a + bamboos[idx], b, c)
    pb = solve(idx + 1, cnt_merge + 1, a, b + bamboos[idx], c)
    pc = solve(idx + 1, cnt_merge + 1, a, b, c + bamboos[idx])
    pn = solve(idx + 1, cnt_merge, a, b, c)
    return min(pa, pb, pc, pn)


print((solve(0, 0, 0, 0, 0)))

-ans = float("inf") +INF = float("inf") +ans = INF -def solve(lst, idx): -    global ans +def solve(idx, cnt_merge, a, b, c): -        # print("qqqqq") -        for i in range(3): -            if len(lst[i]) == 0: -                return -        pa = 10 * (len(lst[0]) - 1) + abs(A - sum(lst[0])) -        pb = 10 * (len(lst[1]) - 1) + abs(B - sum(lst[1])) -        pc = 10 * (len(lst[2]) - 1) + abs(C - sum(lst[2])) -        # print(pa, pb, pc, lst) -        ans = min(ans, pa + pb + pc) -        # print("aaaaaaa") -        return -    for i in range(4): -        nxt_lst = [lst[0][:], lst[1][:], lst[2][:], lst[3][:]] -        nxt_lst[i].append(bamboos[idx]) -        # print(lst, nxt_lst) -        solve(nxt_lst, idx + 1) +        if min(a, b, c) > 0: +            return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt_merge - 3) +        else: +            return INF +    pa = solve(idx + 1, cnt_merge + 1, a + bamboos[idx], b, c) +    pb = solve(idx + 1, cnt_merge + 1, a, b + bamboos[idx], c) +    pc = solve(idx + 1, cnt_merge + 1, a, b, c + bamboos[idx]) +    pn = solve(idx + 1, cnt_merge, a, b, c) +    return min(pa, pb, pc, pn) -empty_lst = [[], [], [], []] -solve(empty_lst, 0) -print(ans) +print((solve(0, 0, 0, 0, 0)))