from itertools import product
n, a, b, c = map(int, input().split())
L = [int(input())for _ in range(n)]

INF = 10**18
ans = INF
for subset in product(range(4), repeat=n):
    cost = 0
    ABC = [[]for _ in range(3)]
    for i, s in enumerate(subset):
        if not s:
            continue
        ABC[s-1].append(L[i])
    if any(not X for X in ABC):
        continue
    for x, X in zip((a, b, c), ABC):
        cost += (len(X)-1)*10
        cost += abs(x-sum(X))
    if cost < ans:
        ans = cost

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)] INF = 10**18 INF 10**18 10 18 ans = INF ans INF for subset in product(range(4), repeat=n):
    cost = 0
    ABC = [[]for _ in range(3)]
    for i, s in enumerate(subset):
        if not s:
            continue
        ABC[s-1].append(L[i])
    if any(not X for X in ABC):
        continue
    for x, X in zip((a, b, c), ABC):
        cost += (len(X)-1)*10
        cost += abs(x-sum(X))
    if cost < ans:
        ans = cost subset product(range(4), repeat=n) product range(4) range 4 repeat=n repeat n cost = 0 cost 0 []for _ in range(3) for _ in range(3) _ range(3) range 3 for _ in range(3) [] ABC = [[]for _ in range(3)] ABC [[]for _ in range(3)] for i, s in enumerate(subset):
        if not s:
            continue
        ABC[s-1].append(L[i])
     i s enumerate(subset) enumerate subset if not s:
            continue
         not s s continue ABC[s-1].append(L[i]) [s-1].append [s-1] ABC s-1 s 1 append L[i] L i if any(not X for X in ABC):
        continue
     any(not X for X in ABC) any not X X continue for x, X in zip((a, b, c), ABC):
        cost += (len(X)-1)*10
        cost += abs(x-sum(X))
     x X zip((a, b, c), ABC) zip (a, b, c) a b c ABC cost += (len(X)-1)*10 cost (len(X)-1)*10 len(X)-1 len(X) len X 1 10 cost += abs(x-sum(X)) cost abs(x-sum(X)) abs x-sum(X) x sum(X) sum X if cost < ans:
        ans = cost cost < ans cost ans ans = cost ans cost print(ans) print ans ans = INF INF ans cost += (len(X)-1)*10 (len(X)-1)*10 cost cost += abs(x-sum(X)) abs(x-sum(X)) cost a, b, c = map(int, input().split()) map(int, input().split()) a cost = 0 0 cost b, c = map(int, input().split()) map(int, input().split()) b INF = 10**18 10**18 INF n, a, b, c = map(int, input().split()) map(int, input().split()) n L = [int(input())for _ in range(n)] [int(input())for _ in range(n)] L c = map(int, input().split()) map(int, input().split()) c ans = cost cost ans ABC = [[]for _ in range(3)] [[]for _ in range(3)] ABC
from itertools import product
n, a, b, c = map(int, input().split())
L = [int(input())for _ in range(n)]

INF = 10**18
ans = INF
for subset in product(range(4), repeat=n):
    cost = 0
    ABC = [[]for _ in range(3)]
    for i, s in enumerate(subset):
        if not s:
            continue
        ABC[s-1].append(L[i])
    if any(not X for X in ABC):
        continue
    for x, X in zip((a, b, c), ABC):
        cost += (len(X)-1)*10
        cost += abs(x-sum(X))
    if cost < ans:
        ans = cost

print(ans)
