
N,A,B,C = map(int, input().split())
bamboos = [int(input()) for _ in range(N)]
#print("---", bamboos)
ans = float("inf")
def solve(lst, idx):
    global ans
    if idx == N:
        #print("qqqqq")
        for i in range(3):
            if len(lst[i]) == 0:
                return

        
        pa = 10 * (len(lst[0])-1) + abs(A - sum(lst[0]))
        pb = 10 * (len(lst[1])-1) + abs(B - sum(lst[1]))
        pc = 10 * (len(lst[2])-1) + abs(C - sum(lst[2]))
        #print(pa, pb, pc, lst)
        ans = min(ans, pa + pb + pc)
        #print("aaaaaaa")
        return

    
    for i in range(4):
        nxt_lst = [lst[0][:], lst[1][:], lst[2][:], lst[3][:]]
        nxt_lst[i].append(bamboos[idx])
        #print(lst, nxt_lst)
        
        solve(nxt_lst, idx+1)

empty_lst =  [[], [], [], []]   
solve(empty_lst, 0)
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 _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input bamboos = [int(input()) for _ in range(N)] bamboos [int(input()) for _ in range(N)] ans = float("inf") ans float("inf") float "inf" def solve(lst, idx):
    global ans
    if idx == N:
        #print("qqqqq")
        for i in range(3):
            if len(lst[i]) == 0:
                return

        
        pa = 10 * (len(lst[0])-1) + abs(A - sum(lst[0]))
        pb = 10 * (len(lst[1])-1) + abs(B - sum(lst[1]))
        pc = 10 * (len(lst[2])-1) + abs(C - sum(lst[2]))
        #print(pa, pb, pc, lst)
        ans = min(ans, pa + pb + pc)
        #print("aaaaaaa")
        return

    
    for i in range(4):
        nxt_lst = [lst[0][:], lst[1][:], lst[2][:], lst[3][:]]
        nxt_lst[i].append(bamboos[idx])
        #print(lst, nxt_lst)
        
        solve(nxt_lst, idx+1) solve global ans if idx == N:
        #print("qqqqq")
        for i in range(3):
            if len(lst[i]) == 0:
                return

        
        pa = 10 * (len(lst[0])-1) + abs(A - sum(lst[0]))
        pb = 10 * (len(lst[1])-1) + abs(B - sum(lst[1]))
        pc = 10 * (len(lst[2])-1) + abs(C - sum(lst[2]))
        #print(pa, pb, pc, lst)
        ans = min(ans, pa + pb + pc)
        #print("aaaaaaa")
        return

    
     idx == N idx N for i in range(3):
            if len(lst[i]) == 0:
                return

        
         i range(3) range 3 if len(lst[i]) == 0:
                return

        
         len(lst[i]) == 0 len(lst[i]) len lst[i] lst i 0 return pa = 10 * (len(lst[0])-1) + abs(A - sum(lst[0])) pa 10 * (len(lst[0])-1) + abs(A - sum(lst[0])) 10 * (len(lst[0])-1) 10 len(lst[0])-1 len(lst[0]) len lst[0] lst 0 1 abs(A - sum(lst[0])) abs A - sum(lst[0]) A sum(lst[0]) sum lst[0] lst 0 pb = 10 * (len(lst[1])-1) + abs(B - sum(lst[1])) pb 10 * (len(lst[1])-1) + abs(B - sum(lst[1])) 10 * (len(lst[1])-1) 10 len(lst[1])-1 len(lst[1]) len lst[1] lst 1 1 abs(B - sum(lst[1])) abs B - sum(lst[1]) B sum(lst[1]) sum lst[1] lst 1 pc = 10 * (len(lst[2])-1) + abs(C - sum(lst[2])) pc 10 * (len(lst[2])-1) + abs(C - sum(lst[2])) 10 * (len(lst[2])-1) 10 len(lst[2])-1 len(lst[2]) len lst[2] lst 2 1 abs(C - sum(lst[2])) abs C - sum(lst[2]) C sum(lst[2]) sum lst[2] lst 2 ans = min(ans, pa + pb + pc) ans min(ans, pa + pb + pc) min ans pa + pb + pc pa + pb pa pb pc return for i in range(4):
        nxt_lst = [lst[0][:], lst[1][:], lst[2][:], lst[3][:]]
        nxt_lst[i].append(bamboos[idx])
        #print(lst, nxt_lst)
        
        solve(nxt_lst, idx+1) i range(4) range 4 nxt_lst = [lst[0][:], lst[1][:], lst[2][:], lst[3][:]] nxt_lst [lst[0][:], lst[1][:], lst[2][:], lst[3][:]] lst[0][:] [0] lst 0 : lst[1][:] [1] lst 1 : lst[2][:] [2] lst 2 : lst[3][:] [3] lst 3 : nxt_lst[i].append(bamboos[idx]) [i].append [i] nxt_lst i append bamboos[idx] bamboos idx solve(nxt_lst, idx+1) solve nxt_lst idx+1 idx 1 lst lst idx idx empty_lst =  [[], [], [], []] empty_lst [[], [], [], []] [] [] [] [] solve(empty_lst, 0) solve empty_lst 0 print(ans) print ans A,B,C = map(int, input().split()) map(int, input().split()) A B,C = map(int, input().split()) map(int, input().split()) B empty_lst =  [[], [], [], []] [[], [], [], []] empty_lst def solve(lst, idx):
    global ans
    if idx == N:
        #print("qqqqq")
        for i in range(3):
            if len(lst[i]) == 0:
                return

        
        pa = 10 * (len(lst[0])-1) + abs(A - sum(lst[0]))
        pb = 10 * (len(lst[1])-1) + abs(B - sum(lst[1]))
        pc = 10 * (len(lst[2])-1) + abs(C - sum(lst[2]))
        #print(pa, pb, pc, lst)
        ans = min(ans, pa + pb + pc)
        #print("aaaaaaa")
        return

    
    for i in range(4):
        nxt_lst = [lst[0][:], lst[1][:], lst[2][:], lst[3][:]]
        nxt_lst[i].append(bamboos[idx])
        #print(lst, nxt_lst)
        
        solve(nxt_lst, idx+1) def solve(lst, idx):
    global ans
    if idx == N:
        #print("qqqqq")
        for i in range(3):
            if len(lst[i]) == 0:
                return

        
        pa = 10 * (len(lst[0])-1) + abs(A - sum(lst[0]))
        pb = 10 * (len(lst[1])-1) + abs(B - sum(lst[1]))
        pc = 10 * (len(lst[2])-1) + abs(C - sum(lst[2]))
        #print(pa, pb, pc, lst)
        ans = min(ans, pa + pb + pc)
        #print("aaaaaaa")
        return

    
    for i in range(4):
        nxt_lst = [lst[0][:], lst[1][:], lst[2][:], lst[3][:]]
        nxt_lst[i].append(bamboos[idx])
        #print(lst, nxt_lst)
        
        solve(nxt_lst, idx+1) solve bamboos = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] bamboos N,A,B,C = map(int, input().split()) map(int, input().split()) N ans = float("inf") float("inf") ans C = map(int, input().split()) map(int, input().split()) C

N,A,B,C = map(int, input().split())
bamboos = [int(input()) for _ in range(N)]
#print("---", bamboos)
ans = float("inf")
def solve(lst, idx):
    global ans
    if idx == N:
        #print("qqqqq")
        for i in range(3):
            if len(lst[i]) == 0:
                return

        
        pa = 10 * (len(lst[0])-1) + abs(A - sum(lst[0]))
        pb = 10 * (len(lst[1])-1) + abs(B - sum(lst[1]))
        pc = 10 * (len(lst[2])-1) + abs(C - sum(lst[2]))
        #print(pa, pb, pc, lst)
        ans = min(ans, pa + pb + pc)
        #print("aaaaaaa")
        return

    
    for i in range(4):
        nxt_lst = [lst[0][:], lst[1][:], lst[2][:], lst[3][:]]
        nxt_lst[i].append(bamboos[idx])
        #print(lst, nxt_lst)
        
        solve(nxt_lst, idx+1)

empty_lst =  [[], [], [], []]   
solve(empty_lst, 0)
print(ans)