from itertools import product

N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]

ans = 10**18
for state in product(range(4), repeat=N):
    K = [[] for _ in range(4)]
    for i, l in enumerate(L):
        K[state[i]].append(l)

    cost = 0
    for d, D in zip((A, B, C), K):
        if len(D) == 0:
            cost += 10**18
        cost += (len(D) - 1) * 10
        cost += abs(d - sum(D))
    ans = min(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)] ans = 10**18 ans 10**18 10 18 for state in product(range(4), repeat=N):
    K = [[] for _ in range(4)]
    for i, l in enumerate(L):
        K[state[i]].append(l)

    cost = 0
    for d, D in zip((A, B, C), K):
        if len(D) == 0:
            cost += 10**18
        cost += (len(D) - 1) * 10
        cost += abs(d - sum(D))
    ans = min(ans, cost) state product(range(4), repeat=N) product range(4) range 4 repeat=N repeat N [] for _ in range(4) for _ in range(4) _ range(4) range 4 for _ in range(4) [] K = [[] for _ in range(4)] K [[] for _ in range(4)] for i, l in enumerate(L):
        K[state[i]].append(l)

     i l enumerate(L) enumerate L K[state[i]].append(l) [state[i]].append [state[i]] K state[i] state i append l cost = 0 cost 0 for d, D in zip((A, B, C), K):
        if len(D) == 0:
            cost += 10**18
        cost += (len(D) - 1) * 10
        cost += abs(d - sum(D))
     d D zip((A, B, C), K) zip (A, B, C) A B C K if len(D) == 0:
            cost += 10**18
         len(D) == 0 len(D) len D 0 cost += 10**18 cost 10**18 10 18 cost += (len(D) - 1) * 10 cost (len(D) - 1) * 10 len(D) - 1 len(D) len D 1 10 cost += abs(d - sum(D)) cost abs(d - sum(D)) abs d - sum(D) d sum(D) sum D ans = min(ans, cost) ans min(ans, cost) min ans cost print(ans) print ans cost += 10**18 10**18 cost N, A, B, C = map(int, input().split()) map(int, input().split()) N cost += (len(D) - 1) * 10 (len(D) - 1) * 10 cost B, C = map(int, input().split()) map(int, input().split()) B A, B, C = map(int, input().split()) map(int, input().split()) A K = [[] for _ in range(4)] [[] for _ in range(4)] K cost += abs(d - sum(D)) abs(d - sum(D)) cost L = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] L cost = 0 0 cost C = map(int, input().split()) map(int, input().split()) C ans = 10**18 10**18 ans ans = min(ans, cost) min(ans, cost) ans
from itertools import product

N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]

ans = 10**18
for state in product(range(4), repeat=N):
    K = [[] for _ in range(4)]
    for i, l in enumerate(L):
        K[state[i]].append(l)

    cost = 0
    for d, D in zip((A, B, C), K):
        if len(D) == 0:
            cost += 10**18
        cost += (len(D) - 1) * 10
        cost += abs(d - sum(D))
    ans = min(ans, cost)

print(ans)
