N,A,B,C=map(int,input().split())
L=[int(input()) for i in range(N)]
R=[0]*N
ans=10**9
def myadd(i):
    if R[i]==3:
        R[i]=0
        myadd(i+1)
    else:
        R[i]+=1
for i in range(4**N-1):
    myadd(0)
    if 1 in R and 2 in R and 3 in R:
        tmp=-30
        t1,t2,t3=0,0,0
        for j in range(N):
            if R[j]==0:
                continue
            if R[j]==1:
                t1+=L[j]
            elif R[j]==2:
                t2+=L[j]
            elif R[j]==3:
                t3+=L[j]
            tmp+=10
        tmp+=abs(A-t1)+abs(B-t2)+abs(C-t3)
        ans=min(tmp,ans)
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 i in range(N) for i in range(N) i range(N) range N for i in range(N) int(input()) int input() input L=[int(input()) for i in range(N)] L [int(input()) for i in range(N)] R=[0]*N R [0]*N [0] 0 N ans=10**9 ans 10**9 10 9 def myadd(i):
    if R[i]==3:
        R[i]=0
        myadd(i+1)
    else:
        R[i]+=1 myadd if R[i]==3:
        R[i]=0
        myadd(i+1)
    else:
        R[i]+=1 R[i]==3 R[i] R i 3 R[i]=0 R[i] R i 0 myadd(i+1) myadd i+1 i 1 R[i]+=1 R[i] R i 1 i i for i in range(4**N-1):
    myadd(0)
    if 1 in R and 2 in R and 3 in R:
        tmp=-30
        t1,t2,t3=0,0,0
        for j in range(N):
            if R[j]==0:
                continue
            if R[j]==1:
                t1+=L[j]
            elif R[j]==2:
                t2+=L[j]
            elif R[j]==3:
                t3+=L[j]
            tmp+=10
        tmp+=abs(A-t1)+abs(B-t2)+abs(C-t3)
        ans=min(tmp,ans) i range(4**N-1) range 4**N-1 4**N 4 N 1 myadd(0) myadd 0 if 1 in R and 2 in R and 3 in R:
        tmp=-30
        t1,t2,t3=0,0,0
        for j in range(N):
            if R[j]==0:
                continue
            if R[j]==1:
                t1+=L[j]
            elif R[j]==2:
                t2+=L[j]
            elif R[j]==3:
                t3+=L[j]
            tmp+=10
        tmp+=abs(A-t1)+abs(B-t2)+abs(C-t3)
        ans=min(tmp,ans) 1 in R and 2 in R and 3 in R 1 in R and 2 in R 1 in R 1 R 2 in R 2 R 3 in R 3 R tmp=-30 tmp -30 t1,t2,t3=0,0,0 t1 0 t2 0 t3 0 for j in range(N):
            if R[j]==0:
                continue
            if R[j]==1:
                t1+=L[j]
            elif R[j]==2:
                t2+=L[j]
            elif R[j]==3:
                t3+=L[j]
            tmp+=10
         j range(N) range N if R[j]==0:
                continue
             R[j]==0 R[j] R j 0 continue if R[j]==1:
                t1+=L[j]
            elif R[j]==2:
                t2+=L[j]
            elif R[j]==3:
                t3+=L[j]
             R[j]==1 R[j] R j 1 t1+=L[j] t1 L[j] L j elif R[j]==2:
                t2+=L[j]
             R[j]==2 R[j] R j 2 t2+=L[j] t2 L[j] L j elif R[j]==3:
                t3+=L[j]
             R[j]==3 R[j] R j 3 t3+=L[j] t3 L[j] L j tmp+=10 tmp 10 tmp+=abs(A-t1)+abs(B-t2)+abs(C-t3) tmp abs(A-t1)+abs(B-t2)+abs(C-t3) abs(A-t1)+abs(B-t2) abs(A-t1) abs A-t1 A t1 abs(B-t2) abs B-t2 B t2 abs(C-t3) abs C-t3 C t3 ans=min(tmp,ans) ans min(tmp,ans) min tmp ans print(ans) print ans R=[0]*N [0]*N R N,A,B,C=map(int,input().split()) map(int,input().split()) N t1+=L[j] L[j] t1 C=map(int,input().split()) map(int,input().split()) C tmp+=10 10 tmp ans=10**9 10**9 ans tmp=-30 -30 tmp t2,t3=0,0,0 0 t2 t2+=L[j] L[j] t2 ans=min(tmp,ans) min(tmp,ans) ans t3=0,0,0 0 t3 B,C=map(int,input().split()) map(int,input().split()) B t1,t2,t3=0,0,0 0 t1 A,B,C=map(int,input().split()) map(int,input().split()) A tmp+=abs(A-t1)+abs(B-t2)+abs(C-t3) abs(A-t1)+abs(B-t2)+abs(C-t3) tmp L=[int(input()) for i in range(N)] [int(input()) for i in range(N)] L def myadd(i):
    if R[i]==3:
        R[i]=0
        myadd(i+1)
    else:
        R[i]+=1 def myadd(i):
    if R[i]==3:
        R[i]=0
        myadd(i+1)
    else:
        R[i]+=1 myadd t3+=L[j] L[j] t3
N,A,B,C=map(int,input().split())
L=[int(input()) for i in range(N)]
R=[0]*N
ans=10**9
def myadd(i):
    if R[i]==3:
        R[i]=0
        myadd(i+1)
    else:
        R[i]+=1
for i in range(4**N-1):
    myadd(0)
    if 1 in R and 2 in R and 3 in R:
        tmp=-30
        t1,t2,t3=0,0,0
        for j in range(N):
            if R[j]==0:
                continue
            if R[j]==1:
                t1+=L[j]
            elif R[j]==2:
                t2+=L[j]
            elif R[j]==3:
                t3+=L[j]
            tmp+=10
        tmp+=abs(A-t1)+abs(B-t2)+abs(C-t3)
        ans=min(tmp,ans)
print(ans)