from itertools import product

n,a,b,c,*L = map(int,open(0).read().split())

li1 = [1,2,3,4]
ans = 10**10
for v in product(li1,repeat = n):
    num = 0
    A,B,C = [],[],[]
    for i in range(n):
        if v[i] == 1:
            A.append(L[i])
        elif v[i] == 2:
            B.append(L[i])
        elif v[i] == 3:
            C.append(L[i])

    if A and B and C:
        num +=abs(sum(A)-a) + max(0,(len(A)-1)*10) + abs(sum(B)-b) + max(0,(len(B)-1)*10)+ abs(sum(C)-c) + max(0,(len(C)-1)*10)
        ans = min(ans,num)

print(ans) from itertools import product n,a,b,c,*L = map(int,open(0).read().split()) n map(int,open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split a b c *L L li1 = [1,2,3,4] li1 [1,2,3,4] 1 2 3 4 ans = 10**10 ans 10**10 10 10 for v in product(li1,repeat = n):
    num = 0
    A,B,C = [],[],[]
    for i in range(n):
        if v[i] == 1:
            A.append(L[i])
        elif v[i] == 2:
            B.append(L[i])
        elif v[i] == 3:
            C.append(L[i])

    if A and B and C:
        num +=abs(sum(A)-a) + max(0,(len(A)-1)*10) + abs(sum(B)-b) + max(0,(len(B)-1)*10)+ abs(sum(C)-c) + max(0,(len(C)-1)*10)
        ans = min(ans,num) v product(li1,repeat = n) product li1 repeat = n repeat n num = 0 num 0 A,B,C = [],[],[] A [] B [] C [] for i in range(n):
        if v[i] == 1:
            A.append(L[i])
        elif v[i] == 2:
            B.append(L[i])
        elif v[i] == 3:
            C.append(L[i])

     i range(n) range n if v[i] == 1:
            A.append(L[i])
        elif v[i] == 2:
            B.append(L[i])
        elif v[i] == 3:
            C.append(L[i])

     v[i] == 1 v[i] v i 1 A.append(L[i]) A.append A append L[i] L i elif v[i] == 2:
            B.append(L[i])
         v[i] == 2 v[i] v i 2 B.append(L[i]) B.append B append L[i] L i elif v[i] == 3:
            C.append(L[i])

     v[i] == 3 v[i] v i 3 C.append(L[i]) C.append C append L[i] L i if A and B and C:
        num +=abs(sum(A)-a) + max(0,(len(A)-1)*10) + abs(sum(B)-b) + max(0,(len(B)-1)*10)+ abs(sum(C)-c) + max(0,(len(C)-1)*10)
        ans = min(ans,num) A and B and C A and B A B C num +=abs(sum(A)-a) + max(0,(len(A)-1)*10) + abs(sum(B)-b) + max(0,(len(B)-1)*10)+ abs(sum(C)-c) + max(0,(len(C)-1)*10) num abs(sum(A)-a) + max(0,(len(A)-1)*10) + abs(sum(B)-b) + max(0,(len(B)-1)*10)+ abs(sum(C)-c) + max(0,(len(C)-1)*10) abs(sum(A)-a) + max(0,(len(A)-1)*10) + abs(sum(B)-b) + max(0,(len(B)-1)*10)+ abs(sum(C)-c) abs(sum(A)-a) + max(0,(len(A)-1)*10) + abs(sum(B)-b) + max(0,(len(B)-1)*10) abs(sum(A)-a) + max(0,(len(A)-1)*10) + abs(sum(B)-b) abs(sum(A)-a) + max(0,(len(A)-1)*10) abs(sum(A)-a) abs sum(A)-a sum(A) sum A a max(0,(len(A)-1)*10) max 0 (len(A)-1)*10 len(A)-1 len(A) len A 1 10 abs(sum(B)-b) abs sum(B)-b sum(B) sum B b max(0,(len(B)-1)*10) max 0 (len(B)-1)*10 len(B)-1 len(B) len B 1 10 abs(sum(C)-c) abs sum(C)-c sum(C) sum C c max(0,(len(C)-1)*10) max 0 (len(C)-1)*10 len(C)-1 len(C) len C 1 10 ans = min(ans,num) ans min(ans,num) min ans num print(ans) print ans ans = 10**10 10**10 ans A,B,C = [],[],[] [] A B,C = [],[],[] [] B b,c,*L = map(int,open(0).read().split()) map(int,open(0).read().split()) b num +=abs(sum(A)-a) + max(0,(len(A)-1)*10) + abs(sum(B)-b) + max(0,(len(B)-1)*10)+ abs(sum(C)-c) + max(0,(len(C)-1)*10) abs(sum(A)-a) + max(0,(len(A)-1)*10) + abs(sum(B)-b) + max(0,(len(B)-1)*10)+ abs(sum(C)-c) + max(0,(len(C)-1)*10) num li1 = [1,2,3,4] [1,2,3,4] li1 num = 0 0 num n,a,b,c,*L = map(int,open(0).read().split()) map(int,open(0).read().split()) n a,b,c,*L = map(int,open(0).read().split()) map(int,open(0).read().split()) a ans = min(ans,num) min(ans,num) ans C = [],[],[] [] C c,*L = map(int,open(0).read().split()) map(int,open(0).read().split()) c
from itertools import product

n,a,b,c,*L = map(int,open(0).read().split())

li1 = [1,2,3,4]
ans = 10**10
for v in product(li1,repeat = n):
    num = 0
    A,B,C = [],[],[]
    for i in range(n):
        if v[i] == 1:
            A.append(L[i])
        elif v[i] == 2:
            B.append(L[i])
        elif v[i] == 3:
            C.append(L[i])

    if A and B and C:
        num +=abs(sum(A)-a) + max(0,(len(A)-1)*10) + abs(sum(B)-b) + max(0,(len(B)-1)*10)+ abs(sum(C)-c) + max(0,(len(C)-1)*10)
        ans = min(ans,num)

print(ans)