n,a,b,c=map(int,input().split())
L=[int(input()) for _ in range(n)]
ans=10**9
for x in range(4**n):
    A,B,C=0,0,0
    cost=0
    for i in range(n):
        r=x%4
        x//=4
        if r==1:
            A+=L[i]
        elif r==2:
            B+=L[i]
        elif r==3:
            C+=L[i]
        if r>0:
            cost+=10
    if A==0 or B==0 or C==0:
        continue
    cost+=-30+abs(A-a)+abs(B-b)+abs(C-c)
    ans=min(ans,cost)
print(ans) n,a,b,c=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split a b c int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input L=[int(input()) for _ in range(n)] L [int(input()) for _ in range(n)] ans=10**9 ans 10**9 10 9 for x in range(4**n):
    A,B,C=0,0,0
    cost=0
    for i in range(n):
        r=x%4
        x//=4
        if r==1:
            A+=L[i]
        elif r==2:
            B+=L[i]
        elif r==3:
            C+=L[i]
        if r>0:
            cost+=10
    if A==0 or B==0 or C==0:
        continue
    cost+=-30+abs(A-a)+abs(B-b)+abs(C-c)
    ans=min(ans,cost) x range(4**n) range 4**n 4 n A,B,C=0,0,0 A 0 B 0 C 0 cost=0 cost 0 for i in range(n):
        r=x%4
        x//=4
        if r==1:
            A+=L[i]
        elif r==2:
            B+=L[i]
        elif r==3:
            C+=L[i]
        if r>0:
            cost+=10
     i range(n) range n r=x%4 r x%4 x 4 x//=4 x 4 if r==1:
            A+=L[i]
        elif r==2:
            B+=L[i]
        elif r==3:
            C+=L[i]
         r==1 r 1 A+=L[i] A L[i] L i elif r==2:
            B+=L[i]
         r==2 r 2 B+=L[i] B L[i] L i elif r==3:
            C+=L[i]
         r==3 r 3 C+=L[i] C L[i] L i if r>0:
            cost+=10
     r>0 r 0 cost+=10 cost 10 if A==0 or B==0 or C==0:
        continue
     A==0 or B==0 or C==0 A==0 or B==0 A==0 A 0 B==0 B 0 C==0 C 0 continue cost+=-30+abs(A-a)+abs(B-b)+abs(C-c) cost -30+abs(A-a)+abs(B-b)+abs(C-c) -30+abs(A-a)+abs(B-b) -30+abs(A-a) -30 abs(A-a) abs A-a A a abs(B-b) abs B-b B b abs(C-c) abs C-c C c ans=min(ans,cost) ans min(ans,cost) min ans cost print(ans) print ans C=0,0,0 0 C cost+=10 10 cost C+=L[i] L[i] C ans=10**9 10**9 ans cost+=-30+abs(A-a)+abs(B-b)+abs(C-c) -30+abs(A-a)+abs(B-b)+abs(C-c) cost cost=0 0 cost ans=min(ans,cost) min(ans,cost) ans r=x%4 x%4 r B+=L[i] L[i] B b,c=map(int,input().split()) map(int,input().split()) b L=[int(input()) for _ in range(n)] [int(input()) for _ in range(n)] L x//=4 4 x a,b,c=map(int,input().split()) map(int,input().split()) a A,B,C=0,0,0 0 A A+=L[i] L[i] A n,a,b,c=map(int,input().split()) map(int,input().split()) n B,C=0,0,0 0 B c=map(int,input().split()) map(int,input().split()) c
n,a,b,c=map(int,input().split())
L=[int(input()) for _ in range(n)]
ans=10**9
for x in range(4**n):
    A,B,C=0,0,0
    cost=0
    for i in range(n):
        r=x%4
        x//=4
        if r==1:
            A+=L[i]
        elif r==2:
            B+=L[i]
        elif r==3:
            C+=L[i]
        if r>0:
            cost+=10
    if A==0 or B==0 or C==0:
        continue
    cost+=-30+abs(A-a)+abs(B-b)+abs(C-c)
    ans=min(ans,cost)
print(ans)
