from itertools import combinations, product
N,A,B,C=map(int, input().split())
l=[int(input()) for _ in range(N)]
ans = float("inf")
for tmp in product(range(4), repeat=N):
    cost = 0
    forA = []
    forB = []
    forC = []
    for i in range(N):
        if tmp[i] == 0:
            forA.append(l[i])
            cost += 10
        elif tmp[i] == 1:
            forB.append(l[i])
            cost += 10
        elif tmp[i] == 2:
            forC.append(l[i])
            cost += 10
    if not (forA and forB and forC):
        continue
    cost -= 30
    toA = sum(forA)
    toB = sum(forB)
    toC = sum(forC)
    cost += abs(toA - A) + abs(toB - B) + abs(toC - C)
    ans = min(ans, cost)

print(ans) from itertools import combinations, 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)] ans = float("inf") ans float("inf") float "inf" for tmp in product(range(4), repeat=N):
    cost = 0
    forA = []
    forB = []
    forC = []
    for i in range(N):
        if tmp[i] == 0:
            forA.append(l[i])
            cost += 10
        elif tmp[i] == 1:
            forB.append(l[i])
            cost += 10
        elif tmp[i] == 2:
            forC.append(l[i])
            cost += 10
    if not (forA and forB and forC):
        continue
    cost -= 30
    toA = sum(forA)
    toB = sum(forB)
    toC = sum(forC)
    cost += abs(toA - A) + abs(toB - B) + abs(toC - C)
    ans = min(ans, cost) tmp product(range(4), repeat=N) product range(4) range 4 repeat=N repeat N cost = 0 cost 0 forA = [] forA [] forB = [] forB [] forC = [] forC [] for i in range(N):
        if tmp[i] == 0:
            forA.append(l[i])
            cost += 10
        elif tmp[i] == 1:
            forB.append(l[i])
            cost += 10
        elif tmp[i] == 2:
            forC.append(l[i])
            cost += 10
     i range(N) range N if tmp[i] == 0:
            forA.append(l[i])
            cost += 10
        elif tmp[i] == 1:
            forB.append(l[i])
            cost += 10
        elif tmp[i] == 2:
            forC.append(l[i])
            cost += 10
     tmp[i] == 0 tmp[i] tmp i 0 forA.append(l[i]) forA.append forA append l[i] l i cost += 10 cost 10 elif tmp[i] == 1:
            forB.append(l[i])
            cost += 10
         tmp[i] == 1 tmp[i] tmp i 1 forB.append(l[i]) forB.append forB append l[i] l i cost += 10 cost 10 elif tmp[i] == 2:
            forC.append(l[i])
            cost += 10
     tmp[i] == 2 tmp[i] tmp i 2 forC.append(l[i]) forC.append forC append l[i] l i cost += 10 cost 10 if not (forA and forB and forC):
        continue
     not (forA and forB and forC) forA and forB and forC forA and forB forA forB forC continue cost -= 30 cost 30 toA = sum(forA) toA sum(forA) sum forA toB = sum(forB) toB sum(forB) sum forB toC = sum(forC) toC sum(forC) sum forC cost += abs(toA - A) + abs(toB - B) + abs(toC - C) cost abs(toA - A) + abs(toB - B) + abs(toC - C) abs(toA - A) + abs(toB - B) abs(toA - A) abs toA - A toA A abs(toB - B) abs toB - B toB B abs(toC - C) abs toC - C toC C ans = min(ans, cost) ans min(ans, cost) min ans cost print(ans) print ans forB = [] [] forB toB = sum(forB) sum(forB) toB ans = min(ans, cost) min(ans, cost) ans forA = [] [] forA toC = sum(forC) sum(forC) toC C=map(int, input().split()) map(int, input().split()) C cost += abs(toA - A) + abs(toB - B) + abs(toC - C) abs(toA - A) + abs(toB - B) + abs(toC - C) cost forC = [] [] forC cost += 10 10 cost ans = float("inf") float("inf") ans cost += 10 10 cost 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 cost = 0 0 cost cost -= 30 30 cost toA = sum(forA) sum(forA) toA cost += 10 10 cost N,A,B,C=map(int, input().split()) map(int, input().split()) N A,B,C=map(int, input().split()) map(int, input().split()) A
from itertools import combinations, product
N,A,B,C=map(int, input().split())
l=[int(input()) for _ in range(N)]
ans = float("inf")
for tmp in product(range(4), repeat=N):
    cost = 0
    forA = []
    forB = []
    forC = []
    for i in range(N):
        if tmp[i] == 0:
            forA.append(l[i])
            cost += 10
        elif tmp[i] == 1:
            forB.append(l[i])
            cost += 10
        elif tmp[i] == 2:
            forC.append(l[i])
            cost += 10
    if not (forA and forB and forC):
        continue
    cost -= 30
    toA = sum(forA)
    toB = sum(forB)
    toC = sum(forC)
    cost += abs(toA - A) + abs(toB - B) + abs(toC - C)
    ans = min(ans, cost)

print(ans)