from itertools import product 
n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]
tar = [a,b,c]
ans = float("inf")
for p in product(range(4),repeat=n):
    mp = 0
    length = [0]*3
    for i,j in enumerate(p):
        if j == 3: continue
        if length[j] > 0: mp += 10
        length[j] += l[i]
    for j in range(3):
        if length[j] == 0: break
        mp += abs(length[j]-tar[j])
    else:
        ans = min(ans, mp)
print(ans) from itertools import product 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 _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input l = [int(input()) for _ in range(n)] l [int(input()) for _ in range(n)] tar = [a,b,c] tar [a,b,c] a b c ans = float("inf") ans float("inf") float "inf" for p in product(range(4),repeat=n):
    mp = 0
    length = [0]*3
    for i,j in enumerate(p):
        if j == 3: continue
        if length[j] > 0: mp += 10
        length[j] += l[i]
    for j in range(3):
        if length[j] == 0: break
        mp += abs(length[j]-tar[j])
    else:
        ans = min(ans, mp) p product(range(4),repeat=n) product range(4) range 4 repeat=n repeat n mp = 0 mp 0 length = [0]*3 length [0]*3 [0] 0 3 for i,j in enumerate(p):
        if j == 3: continue
        if length[j] > 0: mp += 10
        length[j] += l[i]
     i j enumerate(p) enumerate p if j == 3: continue
         j == 3 j 3 if length[j] > 0: mp += 10
         length[j] > 0 length[j] length j 0 length[j] += l[i] length[j] length j l[i] l i for j in range(3):
        if length[j] == 0: break
        mp += abs(length[j]-tar[j])
    else:
        ans = min(ans, mp) j range(3) range 3 if length[j] == 0: break
         length[j] == 0 length[j] length j 0 mp += abs(length[j]-tar[j]) mp abs(length[j]-tar[j]) abs length[j]-tar[j] length[j] length j tar[j] tar j ans = min(ans, mp) ans min(ans, mp) min ans mp print(ans) print ans n,a,b,c = map(int,input().split()) map(int,input().split()) n ans = min(ans, mp) min(ans, mp) ans mp = 0 0 mp length = [0]*3 [0]*3 length b,c = map(int,input().split()) map(int,input().split()) b l = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] l tar = [a,b,c] [a,b,c] tar a,b,c = map(int,input().split()) map(int,input().split()) a c = map(int,input().split()) map(int,input().split()) c ans = float("inf") float("inf") ans mp += abs(length[j]-tar[j]) abs(length[j]-tar[j]) mp
from itertools import product 
n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]
tar = [a,b,c]
ans = float("inf")
for p in product(range(4),repeat=n):
    mp = 0
    length = [0]*3
    for i,j in enumerate(p):
        if j == 3: continue
        if length[j] > 0: mp += 10
        length[j] += l[i]
    for j in range(3):
        if length[j] == 0: break
        mp += abs(length[j]-tar[j])
    else:
        ans = min(ans, mp)
print(ans)