N,A,B,C=map(int,input().split())
l=[]
for i in range(N):
    l.append(int(input()))

from itertools import product

P=product(range(4),repeat=N)

ans=1000000000
for p in P:
    A_len=0
    B_len=0
    C_len=0
    temp=0
    for i in range(N):
        n=int(p[i])
        if n==3:
            if A_len!=0:
                temp+=10
            A_len+=l[i]
        elif n==2:
            if B_len!=0:
                temp+=10
            B_len+=l[i]
        elif n==1:
            if C_len!=0:
                temp+=10
            C_len+=l[i]

    if A_len!=0 and B_len!=0 and C_len!=0:
        temp+=abs(A-A_len)
        temp+=abs(B-B_len)
        temp+=abs(C-C_len)

        ans=min(ans,temp)

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 l=[] l [] for i in range(N):
    l.append(int(input())) i range(N) range N l.append(int(input())) l.append l append int(input()) int input() input from itertools import product P=product(range(4),repeat=N) P product(range(4),repeat=N) product range(4) range 4 repeat=N repeat N ans=1000000000 ans 1000000000 for p in P:
    A_len=0
    B_len=0
    C_len=0
    temp=0
    for i in range(N):
        n=int(p[i])
        if n==3:
            if A_len!=0:
                temp+=10
            A_len+=l[i]
        elif n==2:
            if B_len!=0:
                temp+=10
            B_len+=l[i]
        elif n==1:
            if C_len!=0:
                temp+=10
            C_len+=l[i]

    if A_len!=0 and B_len!=0 and C_len!=0:
        temp+=abs(A-A_len)
        temp+=abs(B-B_len)
        temp+=abs(C-C_len)

        ans=min(ans,temp) p P A_len=0 A_len 0 B_len=0 B_len 0 C_len=0 C_len 0 temp=0 temp 0 for i in range(N):
        n=int(p[i])
        if n==3:
            if A_len!=0:
                temp+=10
            A_len+=l[i]
        elif n==2:
            if B_len!=0:
                temp+=10
            B_len+=l[i]
        elif n==1:
            if C_len!=0:
                temp+=10
            C_len+=l[i]

     i range(N) range N n=int(p[i]) n int(p[i]) int p[i] p i if n==3:
            if A_len!=0:
                temp+=10
            A_len+=l[i]
        elif n==2:
            if B_len!=0:
                temp+=10
            B_len+=l[i]
        elif n==1:
            if C_len!=0:
                temp+=10
            C_len+=l[i]

     n==3 n 3 if A_len!=0:
                temp+=10
             A_len!=0 A_len 0 temp+=10 temp 10 A_len+=l[i] A_len l[i] l i elif n==2:
            if B_len!=0:
                temp+=10
            B_len+=l[i]
         n==2 n 2 if B_len!=0:
                temp+=10
             B_len!=0 B_len 0 temp+=10 temp 10 B_len+=l[i] B_len l[i] l i elif n==1:
            if C_len!=0:
                temp+=10
            C_len+=l[i]

     n==1 n 1 if C_len!=0:
                temp+=10
             C_len!=0 C_len 0 temp+=10 temp 10 C_len+=l[i] C_len l[i] l i if A_len!=0 and B_len!=0 and C_len!=0:
        temp+=abs(A-A_len)
        temp+=abs(B-B_len)
        temp+=abs(C-C_len)

        ans=min(ans,temp) A_len!=0 and B_len!=0 and C_len!=0 A_len!=0 and B_len!=0 A_len!=0 A_len 0 B_len!=0 B_len 0 C_len!=0 C_len 0 temp+=abs(A-A_len) temp abs(A-A_len) abs A-A_len A A_len temp+=abs(B-B_len) temp abs(B-B_len) abs B-B_len B B_len temp+=abs(C-C_len) temp abs(C-C_len) abs C-C_len C C_len ans=min(ans,temp) ans min(ans,temp) min ans temp print(ans) print ans A,B,C=map(int,input().split()) map(int,input().split()) A temp+=abs(C-C_len) abs(C-C_len) temp B_len=0 0 B_len l=[] [] l B,C=map(int,input().split()) map(int,input().split()) B ans=min(ans,temp) min(ans,temp) ans N,A,B,C=map(int,input().split()) map(int,input().split()) N A_len+=l[i] l[i] A_len temp+=10 10 temp temp+=abs(A-A_len) abs(A-A_len) temp ans=1000000000 1000000000 ans B_len+=l[i] l[i] B_len P=product(range(4),repeat=N) product(range(4),repeat=N) P n=int(p[i]) int(p[i]) n A_len=0 0 A_len temp+=10 10 temp C=map(int,input().split()) map(int,input().split()) C temp+=10 10 temp C_len=0 0 C_len temp+=abs(B-B_len) abs(B-B_len) temp temp=0 0 temp C_len+=l[i] l[i] C_len
N,A,B,C=map(int,input().split())
l=[]
for i in range(N):
    l.append(int(input()))

from itertools import product

P=product(range(4),repeat=N)

ans=1000000000
for p in P:
    A_len=0
    B_len=0
    C_len=0
    temp=0
    for i in range(N):
        n=int(p[i])
        if n==3:
            if A_len!=0:
                temp+=10
            A_len+=l[i]
        elif n==2:
            if B_len!=0:
                temp+=10
            B_len+=l[i]
        elif n==1:
            if C_len!=0:
                temp+=10
            C_len+=l[i]

    if A_len!=0 and B_len!=0 and C_len!=0:
        temp+=abs(A-A_len)
        temp+=abs(B-B_len)
        temp+=abs(C-C_len)

        ans=min(ans,temp)

print(ans)

