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

from itertools import product

ans = 10**10
for pro in product([0,1,2,3], repeat= N):
    cost,lena,lenb,lenc = -30,0,0,0
    for i in range(N):
        if pro[i] == 1:
            lena += L[i]
            cost += 10
        elif pro[i] == 2:
            lenb += L[i]
            cost += 10
        elif pro[i] == 3:
            lenc += L[i]
            cost += 10
    if lena == 0 or lenb == 0 or lenc == 0:
        continue
    cost += abs(A-lena) + abs(B-lenb) + abs(C-lenc)
    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 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)] from itertools import product ans = 10**10 ans 10**10 10 10 for pro in product([0,1,2,3], repeat= N):
    cost,lena,lenb,lenc = -30,0,0,0
    for i in range(N):
        if pro[i] == 1:
            lena += L[i]
            cost += 10
        elif pro[i] == 2:
            lenb += L[i]
            cost += 10
        elif pro[i] == 3:
            lenc += L[i]
            cost += 10
    if lena == 0 or lenb == 0 or lenc == 0:
        continue
    cost += abs(A-lena) + abs(B-lenb) + abs(C-lenc)
    ans = min(ans,cost) pro product([0,1,2,3], repeat= N) product [0,1,2,3] 0 1 2 3 repeat= N repeat N cost,lena,lenb,lenc = -30,0,0,0 cost -30 lena 0 lenb 0 lenc 0 for i in range(N):
        if pro[i] == 1:
            lena += L[i]
            cost += 10
        elif pro[i] == 2:
            lenb += L[i]
            cost += 10
        elif pro[i] == 3:
            lenc += L[i]
            cost += 10
     i range(N) range N if pro[i] == 1:
            lena += L[i]
            cost += 10
        elif pro[i] == 2:
            lenb += L[i]
            cost += 10
        elif pro[i] == 3:
            lenc += L[i]
            cost += 10
     pro[i] == 1 pro[i] pro i 1 lena += L[i] lena L[i] L i cost += 10 cost 10 elif pro[i] == 2:
            lenb += L[i]
            cost += 10
         pro[i] == 2 pro[i] pro i 2 lenb += L[i] lenb L[i] L i cost += 10 cost 10 elif pro[i] == 3:
            lenc += L[i]
            cost += 10
     pro[i] == 3 pro[i] pro i 3 lenc += L[i] lenc L[i] L i cost += 10 cost 10 if lena == 0 or lenb == 0 or lenc == 0:
        continue
     lena == 0 or lenb == 0 or lenc == 0 lena == 0 or lenb == 0 lena == 0 lena 0 lenb == 0 lenb 0 lenc == 0 lenc 0 continue cost += abs(A-lena) + abs(B-lenb) + abs(C-lenc) cost abs(A-lena) + abs(B-lenb) + abs(C-lenc) abs(A-lena) + abs(B-lenb) abs(A-lena) abs A-lena A lena abs(B-lenb) abs B-lenb B lenb abs(C-lenc) abs C-lenc C lenc ans = min(ans,cost) ans min(ans,cost) min ans cost print(ans) print ans L = [int(input()) for i in range(N)] [int(input()) for i in range(N)] L lena += L[i] L[i] lena cost += abs(A-lena) + abs(B-lenb) + abs(C-lenc) abs(A-lena) + abs(B-lenb) + abs(C-lenc) cost B,C = map(int,input().split()) map(int,input().split()) B cost += 10 10 cost N,A,B,C = map(int,input().split()) map(int,input().split()) N lena,lenb,lenc = -30,0,0,0 0 lena cost += 10 10 cost lenb += L[i] L[i] lenb C = map(int,input().split()) map(int,input().split()) C ans = min(ans,cost) min(ans,cost) ans lenc += L[i] L[i] lenc ans = 10**10 10**10 ans cost,lena,lenb,lenc = -30,0,0,0 -30 cost lenb,lenc = -30,0,0,0 0 lenb lenc = -30,0,0,0 0 lenc A,B,C = map(int,input().split()) map(int,input().split()) A cost += 10 10 cost
N,A,B,C = map(int,input().split())
L = [int(input()) for i in range(N)]

from itertools import product

ans = 10**10
for pro in product([0,1,2,3], repeat= N):
    cost,lena,lenb,lenc = -30,0,0,0
    for i in range(N):
        if pro[i] == 1:
            lena += L[i]
            cost += 10
        elif pro[i] == 2:
            lenb += L[i]
            cost += 10
        elif pro[i] == 3:
            lenc += L[i]
            cost += 10
    if lena == 0 or lenb == 0 or lenc == 0:
        continue
    cost += abs(A-lena) + abs(B-lenb) + abs(C-lenc)
    ans = min(ans,cost)
print(ans)
