
N,A,B,C=map(int, input().split())

L=[]
for i in range(N):
    l=int(input())
    L.append(l)
L=sorted(L, reverse=True)

combs=[]
for b in range(4**N):
    nowlist=[[],[],[],[]]
    for i in range(N):
        mod=b%4
        nowlist[mod].append(L[i])
        b=b//4
    combs.append(nowlist)

#print(combs)

abc=[A,B,C]

ans=float("INF")
for c in combs:
    now=0
    for i in range(3):
        cn=c[i]
        n=abc[i]
        if len(cn)==0:
            break
        now+=(len(cn)-1)*10
        now+=abs(sum(cn)-n)
        if i==2:
            ans=min(ans, now)

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=int(input())
    L.append(l) i range(N) range N l=int(input()) l int(input()) int input() input L.append(l) L.append L append l L=sorted(L, reverse=True) L sorted(L, reverse=True) sorted L reverse=True reverse True combs=[] combs [] for b in range(4**N):
    nowlist=[[],[],[],[]]
    for i in range(N):
        mod=b%4
        nowlist[mod].append(L[i])
        b=b//4
    combs.append(nowlist)

#print(combs) b range(4**N) range 4**N 4 N nowlist=[[],[],[],[]] nowlist [[],[],[],[]] [] [] [] [] for i in range(N):
        mod=b%4
        nowlist[mod].append(L[i])
        b=b//4
     i range(N) range N mod=b%4 mod b%4 b 4 nowlist[mod].append(L[i]) [mod].append [mod] nowlist mod append L[i] L i b=b//4 b b//4 b 4 combs.append(nowlist) combs.append combs append nowlist abc=[A,B,C] abc [A,B,C] A B C ans=float("INF") ans float("INF") float "INF" for c in combs:
    now=0
    for i in range(3):
        cn=c[i]
        n=abc[i]
        if len(cn)==0:
            break
        now+=(len(cn)-1)*10
        now+=abs(sum(cn)-n)
        if i==2:
            ans=min(ans, now) c combs now=0 now 0 for i in range(3):
        cn=c[i]
        n=abc[i]
        if len(cn)==0:
            break
        now+=(len(cn)-1)*10
        now+=abs(sum(cn)-n)
        if i==2:
            ans=min(ans, now) i range(3) range 3 cn=c[i] cn c[i] c i n=abc[i] n abc[i] abc i if len(cn)==0:
            break
         len(cn)==0 len(cn) len cn 0 break now+=(len(cn)-1)*10 now (len(cn)-1)*10 len(cn)-1 len(cn) len cn 1 10 now+=abs(sum(cn)-n) now abs(sum(cn)-n) abs sum(cn)-n sum(cn) sum cn n if i==2:
            ans=min(ans, now) i==2 i 2 ans=min(ans, now) ans min(ans, now) min ans now print(ans) print ans N,A,B,C=map(int, input().split()) map(int, input().split()) N now+=abs(sum(cn)-n) abs(sum(cn)-n) now L=[] [] L now+=(len(cn)-1)*10 (len(cn)-1)*10 now B,C=map(int, input().split()) map(int, input().split()) B now=0 0 now ans=float("INF") float("INF") ans b=b//4 b//4 b L=sorted(L, reverse=True) sorted(L, reverse=True) L A,B,C=map(int, input().split()) map(int, input().split()) A nowlist=[[],[],[],[]] [[],[],[],[]] nowlist ans=min(ans, now) min(ans, now) ans C=map(int, input().split()) map(int, input().split()) C l=int(input()) int(input()) l abc=[A,B,C] [A,B,C] abc mod=b%4 b%4 mod cn=c[i] c[i] cn n=abc[i] abc[i] n combs=[] [] combs

N,A,B,C=map(int, input().split())

L=[]
for i in range(N):
    l=int(input())
    L.append(l)
L=sorted(L, reverse=True)

combs=[]
for b in range(4**N):
    nowlist=[[],[],[],[]]
    for i in range(N):
        mod=b%4
        nowlist[mod].append(L[i])
        b=b//4
    combs.append(nowlist)

#print(combs)

abc=[A,B,C]

ans=float("INF")
for c in combs:
    now=0
    for i in range(3):
        cn=c[i]
        n=abc[i]
        if len(cn)==0:
            break
        now+=(len(cn)-1)*10
        now+=abs(sum(cn)-n)
        if i==2:
            ans=min(ans, now)

print(ans)

