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

from itertools import product
from copy import deepcopy
li1 = [4,1,2,3]
ans = 10**10
for v in product(li1,repeat = n):
    #print(v)
    num = 0
    A,B,C,NO = [],[],[],[]
    for i in range(n):
        if v[i] == 1:
            #if L[i] not in (a,b,c):
            A.append(L[i])
        elif v[i] == 2:
            #if L[i] not in (a,b,c):
            B.append(L[i])
        elif v[i] == 3:
            #if L[i] not in (a,b,c):
            C.append(L[i])
        elif v[i] == 4:
            NO.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(num,ans,A,B,C,max(0,(len(A)-1)*10),max(0,(len(B)-1)*10))
print(ans) 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 L.sort(reverse = True) L.sort L sort reverse = True reverse True from itertools import product from copy import deepcopy li1 = [4,1,2,3] li1 [4,1,2,3] 4 1 2 3 ans = 10**10 ans 10**10 10 10 for v in product(li1,repeat = n):
    #print(v)
    num = 0
    A,B,C,NO = [],[],[],[]
    for i in range(n):
        if v[i] == 1:
            #if L[i] not in (a,b,c):
            A.append(L[i])
        elif v[i] == 2:
            #if L[i] not in (a,b,c):
            B.append(L[i])
        elif v[i] == 3:
            #if L[i] not in (a,b,c):
            C.append(L[i])
        elif v[i] == 4:
            NO.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(num,ans,A,B,C,max(0,(len(A)-1)*10),max(0,(len(B)-1)*10)) v product(li1,repeat = n) product li1 repeat = n repeat n num = 0 num 0 A,B,C,NO = [],[],[],[] A [] B [] C [] NO [] for i in range(n):
        if v[i] == 1:
            #if L[i] not in (a,b,c):
            A.append(L[i])
        elif v[i] == 2:
            #if L[i] not in (a,b,c):
            B.append(L[i])
        elif v[i] == 3:
            #if L[i] not in (a,b,c):
            C.append(L[i])
        elif v[i] == 4:
            NO.append(L[i])
     i range(n) range n if v[i] == 1:
            #if L[i] not in (a,b,c):
            A.append(L[i])
        elif v[i] == 2:
            #if L[i] not in (a,b,c):
            B.append(L[i])
        elif v[i] == 3:
            #if L[i] not in (a,b,c):
            C.append(L[i])
        elif v[i] == 4:
            NO.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:
            #if L[i] not in (a,b,c):
            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:
            #if L[i] not in (a,b,c):
            C.append(L[i])
         v[i] == 3 v[i] v i 3 C.append(L[i]) C.append C append L[i] L i elif v[i] == 4:
            NO.append(L[i])
     v[i] == 4 v[i] v i 4 NO.append(L[i]) NO.append NO 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)
    #print(num,ans,A,B,C,max(0,(len(A)-1)*10),max(0,(len(B)-1)*10)) 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 NO = [],[],[],[] [] NO B,C,NO = [],[],[],[] [] B A,B,C,NO = [],[],[],[] [] A a,b,c,*L = map(int,open(0).read().split()) map(int,open(0).read().split()) a ans = 10**10 10**10 ans c,*L = map(int,open(0).read().split()) map(int,open(0).read().split()) c ans = min(ans,num) min(ans,num) ans C,NO = [],[],[],[] [] 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) 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 b,c,*L = map(int,open(0).read().split()) map(int,open(0).read().split()) b li1 = [4,1,2,3] [4,1,2,3] li1 num = 0 0 num n,a,b,c,*L = map(int,open(0).read().split()) map(int,open(0).read().split()) n
n,a,b,c,*L = map(int,open(0).read().split())
L.sort(reverse = True)

from itertools import product
from copy import deepcopy
li1 = [4,1,2,3]
ans = 10**10
for v in product(li1,repeat = n):
    #print(v)
    num = 0
    A,B,C,NO = [],[],[],[]
    for i in range(n):
        if v[i] == 1:
            #if L[i] not in (a,b,c):
            A.append(L[i])
        elif v[i] == 2:
            #if L[i] not in (a,b,c):
            B.append(L[i])
        elif v[i] == 3:
            #if L[i] not in (a,b,c):
            C.append(L[i])
        elif v[i] == 4:
            NO.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(num,ans,A,B,C,max(0,(len(A)-1)*10),max(0,(len(B)-1)*10))
print(ans)