n,a,b,c=map(int,input().split())
L=[]

def base10to(n,b):
    if n//b:
        return base10to(n//b,b)+str(n%b)
    return str(n%b)

for i in range(n):
    L.append(int(input()))
ans=10**10
for i in range(4**n):
    S=base10to(i,4)
    S=S.zfill(n)
    A=[]
    B=[]
    C=[]
    for j in range(n):
        if S[j]=='0':
            continue
        elif S[j]=='1':
            A.append(L[j])
        elif S[j]=='2':
            B.append(L[j])
        else:
            C.append(L[j])
    if A and B and C:
        ans=min(ans,abs(a-sum(A))+(len(A)-1)*10+abs(b-sum(B))+(len(B)-1)*10+abs(c-sum(C))+(len(C)-1)*10)
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 [] def base10to(n,b):
    if n//b:
        return base10to(n//b,b)+str(n%b)
    return str(n%b) base10to if n//b:
        return base10to(n//b,b)+str(n%b)
     n//b n b return base10to(n//b,b)+str(n%b) base10to(n//b,b)+str(n%b) base10to(n//b,b) base10to n//b n b b str(n%b) str n%b n b return str(n%b) str(n%b) str n%b n b n n b b 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 ans=10**10 ans 10**10 10 10 for i in range(4**n):
    S=base10to(i,4)
    S=S.zfill(n)
    A=[]
    B=[]
    C=[]
    for j in range(n):
        if S[j]=='0':
            continue
        elif S[j]=='1':
            A.append(L[j])
        elif S[j]=='2':
            B.append(L[j])
        else:
            C.append(L[j])
    if A and B and C:
        ans=min(ans,abs(a-sum(A))+(len(A)-1)*10+abs(b-sum(B))+(len(B)-1)*10+abs(c-sum(C))+(len(C)-1)*10) i range(4**n) range 4**n 4 n S=base10to(i,4) S base10to(i,4) base10to i 4 S=S.zfill(n) S S.zfill(n) S.zfill S zfill n A=[] A [] B=[] B [] C=[] C [] for j in range(n):
        if S[j]=='0':
            continue
        elif S[j]=='1':
            A.append(L[j])
        elif S[j]=='2':
            B.append(L[j])
        else:
            C.append(L[j])
     j range(n) range n if S[j]=='0':
            continue
        elif S[j]=='1':
            A.append(L[j])
        elif S[j]=='2':
            B.append(L[j])
        else:
            C.append(L[j])
     S[j]=='0' S[j] S j '0' continue elif S[j]=='1':
            A.append(L[j])
         S[j]=='1' S[j] S j '1' A.append(L[j]) A.append A append L[j] L j elif S[j]=='2':
            B.append(L[j])
         S[j]=='2' S[j] S j '2' B.append(L[j]) B.append B append L[j] L j C.append(L[j]) C.append C append L[j] L j if A and B and C:
        ans=min(ans,abs(a-sum(A))+(len(A)-1)*10+abs(b-sum(B))+(len(B)-1)*10+abs(c-sum(C))+(len(C)-1)*10) A and B and C A and B A B C ans=min(ans,abs(a-sum(A))+(len(A)-1)*10+abs(b-sum(B))+(len(B)-1)*10+abs(c-sum(C))+(len(C)-1)*10) ans min(ans,abs(a-sum(A))+(len(A)-1)*10+abs(b-sum(B))+(len(B)-1)*10+abs(c-sum(C))+(len(C)-1)*10) min ans abs(a-sum(A))+(len(A)-1)*10+abs(b-sum(B))+(len(B)-1)*10+abs(c-sum(C))+(len(C)-1)*10 abs(a-sum(A))+(len(A)-1)*10+abs(b-sum(B))+(len(B)-1)*10+abs(c-sum(C)) abs(a-sum(A))+(len(A)-1)*10+abs(b-sum(B))+(len(B)-1)*10 abs(a-sum(A))+(len(A)-1)*10+abs(b-sum(B)) abs(a-sum(A))+(len(A)-1)*10 abs(a-sum(A)) abs a-sum(A) a sum(A) sum A (len(A)-1)*10 len(A)-1 len(A) len A 1 10 abs(b-sum(B)) abs b-sum(B) b sum(B) sum B (len(B)-1)*10 len(B)-1 len(B) len B 1 10 abs(c-sum(C)) abs c-sum(C) c sum(C) sum C (len(C)-1)*10 len(C)-1 len(C) len C 1 10 print(ans) print ans L=[] [] L ans=min(ans,abs(a-sum(A))+(len(A)-1)*10+abs(b-sum(B))+(len(B)-1)*10+abs(c-sum(C))+(len(C)-1)*10) min(ans,abs(a-sum(A))+(len(A)-1)*10+abs(b-sum(B))+(len(B)-1)*10+abs(c-sum(C))+(len(C)-1)*10) ans B=[] [] B C=[] [] C n,a,b,c=map(int,input().split()) map(int,input().split()) n b,c=map(int,input().split()) map(int,input().split()) b a,b,c=map(int,input().split()) map(int,input().split()) a S=base10to(i,4) base10to(i,4) S def base10to(n,b):
    if n//b:
        return base10to(n//b,b)+str(n%b)
    return str(n%b) def base10to(n,b):
    if n//b:
        return base10to(n//b,b)+str(n%b)
    return str(n%b) base10to ans=10**10 10**10 ans S=S.zfill(n) S.zfill(n) S c=map(int,input().split()) map(int,input().split()) c A=[] [] A
n,a,b,c=map(int,input().split())
L=[]

def base10to(n,b):
    if n//b:
        return base10to(n//b,b)+str(n%b)
    return str(n%b)

for i in range(n):
    L.append(int(input()))
ans=10**10
for i in range(4**n):
    S=base10to(i,4)
    S=S.zfill(n)
    A=[]
    B=[]
    C=[]
    for j in range(n):
        if S[j]=='0':
            continue
        elif S[j]=='1':
            A.append(L[j])
        elif S[j]=='2':
            B.append(L[j])
        else:
            C.append(L[j])
    if A and B and C:
        ans=min(ans,abs(a-sum(A))+(len(A)-1)*10+abs(b-sum(B))+(len(B)-1)*10+abs(c-sum(C))+(len(C)-1)*10)
print(ans)