import itertools
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]
ans = float('inf')
for bit in itertools.product(range(4), repeat=N):
    ABC = [0]*3
    cost = 0
    for i, abc in enumerate(bit):
        if abc == 3:
            continue
        ABC[abc] += L[i]
        if ABC[abc] != L[i]:
            cost += 10
    if 0 in ABC:
        continue
    cost += abs(ABC[0] - A) + abs(ABC[1] - B) + abs(ABC[2] - C)
    ans = min(ans, cost)
print(ans) import itertools itertools 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)] ans = float('inf') ans float('inf') float 'inf' for bit in itertools.product(range(4), repeat=N):
    ABC = [0]*3
    cost = 0
    for i, abc in enumerate(bit):
        if abc == 3:
            continue
        ABC[abc] += L[i]
        if ABC[abc] != L[i]:
            cost += 10
    if 0 in ABC:
        continue
    cost += abs(ABC[0] - A) + abs(ABC[1] - B) + abs(ABC[2] - C)
    ans = min(ans, cost) bit itertools.product(range(4), repeat=N) itertools.product itertools product range(4) range 4 repeat=N repeat N ABC = [0]*3 ABC [0]*3 [0] 0 3 cost = 0 cost 0 for i, abc in enumerate(bit):
        if abc == 3:
            continue
        ABC[abc] += L[i]
        if ABC[abc] != L[i]:
            cost += 10
     i abc enumerate(bit) enumerate bit if abc == 3:
            continue
         abc == 3 abc 3 continue ABC[abc] += L[i] ABC[abc] ABC abc L[i] L i if ABC[abc] != L[i]:
            cost += 10
     ABC[abc] != L[i] ABC[abc] ABC abc L[i] L i cost += 10 cost 10 if 0 in ABC:
        continue
     0 in ABC 0 ABC continue cost += abs(ABC[0] - A) + abs(ABC[1] - B) + abs(ABC[2] - C) cost abs(ABC[0] - A) + abs(ABC[1] - B) + abs(ABC[2] - C) abs(ABC[0] - A) + abs(ABC[1] - B) abs(ABC[0] - A) abs ABC[0] - A ABC[0] ABC 0 A abs(ABC[1] - B) abs ABC[1] - B ABC[1] ABC 1 B abs(ABC[2] - C) abs ABC[2] - C ABC[2] ABC 2 C ans = min(ans, cost) ans min(ans, cost) min ans cost print(ans) print ans cost += abs(ABC[0] - A) + abs(ABC[1] - B) + abs(ABC[2] - C) abs(ABC[0] - A) + abs(ABC[1] - B) + abs(ABC[2] - C) cost N, A, B, C = map(int, input().split()) map(int, input().split()) N ABC = [0]*3 [0]*3 ABC cost = 0 0 cost A, B, C = map(int, input().split()) map(int, input().split()) A ans = float('inf') float('inf') ans cost += 10 10 cost ans = min(ans, cost) min(ans, cost) ans B, C = map(int, input().split()) map(int, input().split()) B L = [int(input()) for i in range(N)] [int(input()) for i in range(N)] L C = map(int, input().split()) map(int, input().split()) C
import itertools
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]
ans = float('inf')
for bit in itertools.product(range(4), repeat=N):
    ABC = [0]*3
    cost = 0
    for i, abc in enumerate(bit):
        if abc == 3:
            continue
        ABC[abc] += L[i]
        if ABC[abc] != L[i]:
            cost += 10
    if 0 in ABC:
        continue
    cost += abs(ABC[0] - A) + abs(ABC[1] - B) + abs(ABC[2] - C)
    ans = min(ans, cost)
print(ans)
