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

import itertools

Target = itertools.product([0, 1, 2, 3], repeat=N)

INF = 10 ** 9
#Target = [(1,2,2,2,3)]
ans = INF
for T in Target:
    A_sum = 0
    B_sum = 0
    C_sum = 0
    A_cost = 0
    B_cost = 0
    C_cost = 0
    for i in range(N):
        if T[i] == 0: continue
        if T[i] == 1:
            if A_sum == 0:
                A_sum += L_list[i]
            else:
                A_sum += L_list[i]
                A_cost += 10
        if T[i] == 2:
            if B_sum == 0:
                B_sum += L_list[i]
            else:
                B_sum += L_list[i]
                B_cost += 10
        if T[i] == 3:
            if C_sum == 0:
                C_sum += L_list[i]
            else:
                C_sum += L_list[i]
                C_cost += 10

    if min(A_sum, B_sum, C_sum) == 0: continue

    ans = min(ans, abs(A - A_sum)+A_cost + abs(B - B_sum)+B_cost + abs(C - C_sum)+C_cost)
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 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_list = [int(input()) for i in range(N)] L_list [int(input()) for i in range(N)] import itertools itertools Target = itertools.product([0, 1, 2, 3], repeat=N) Target itertools.product([0, 1, 2, 3], repeat=N) itertools.product itertools product [0, 1, 2, 3] 0 1 2 3 repeat=N repeat N INF = 10 ** 9 INF 10 ** 9 10 9 ans = INF ans INF for T in Target:
    A_sum = 0
    B_sum = 0
    C_sum = 0
    A_cost = 0
    B_cost = 0
    C_cost = 0
    for i in range(N):
        if T[i] == 0: continue
        if T[i] == 1:
            if A_sum == 0:
                A_sum += L_list[i]
            else:
                A_sum += L_list[i]
                A_cost += 10
        if T[i] == 2:
            if B_sum == 0:
                B_sum += L_list[i]
            else:
                B_sum += L_list[i]
                B_cost += 10
        if T[i] == 3:
            if C_sum == 0:
                C_sum += L_list[i]
            else:
                C_sum += L_list[i]
                C_cost += 10

    if min(A_sum, B_sum, C_sum) == 0: continue

    ans = min(ans, abs(A - A_sum)+A_cost + abs(B - B_sum)+B_cost + abs(C - C_sum)+C_cost) T Target A_sum = 0 A_sum 0 B_sum = 0 B_sum 0 C_sum = 0 C_sum 0 A_cost = 0 A_cost 0 B_cost = 0 B_cost 0 C_cost = 0 C_cost 0 for i in range(N):
        if T[i] == 0: continue
        if T[i] == 1:
            if A_sum == 0:
                A_sum += L_list[i]
            else:
                A_sum += L_list[i]
                A_cost += 10
        if T[i] == 2:
            if B_sum == 0:
                B_sum += L_list[i]
            else:
                B_sum += L_list[i]
                B_cost += 10
        if T[i] == 3:
            if C_sum == 0:
                C_sum += L_list[i]
            else:
                C_sum += L_list[i]
                C_cost += 10

     i range(N) range N if T[i] == 0: continue
         T[i] == 0 T[i] T i 0 if T[i] == 1:
            if A_sum == 0:
                A_sum += L_list[i]
            else:
                A_sum += L_list[i]
                A_cost += 10
         T[i] == 1 T[i] T i 1 if A_sum == 0:
                A_sum += L_list[i]
            else:
                A_sum += L_list[i]
                A_cost += 10
         A_sum == 0 A_sum 0 A_sum += L_list[i] A_sum L_list[i] L_list i A_sum += L_list[i] A_sum L_list[i] L_list i A_cost += 10 A_cost 10 if T[i] == 2:
            if B_sum == 0:
                B_sum += L_list[i]
            else:
                B_sum += L_list[i]
                B_cost += 10
         T[i] == 2 T[i] T i 2 if B_sum == 0:
                B_sum += L_list[i]
            else:
                B_sum += L_list[i]
                B_cost += 10
         B_sum == 0 B_sum 0 B_sum += L_list[i] B_sum L_list[i] L_list i B_sum += L_list[i] B_sum L_list[i] L_list i B_cost += 10 B_cost 10 if T[i] == 3:
            if C_sum == 0:
                C_sum += L_list[i]
            else:
                C_sum += L_list[i]
                C_cost += 10

     T[i] == 3 T[i] T i 3 if C_sum == 0:
                C_sum += L_list[i]
            else:
                C_sum += L_list[i]
                C_cost += 10

     C_sum == 0 C_sum 0 C_sum += L_list[i] C_sum L_list[i] L_list i C_sum += L_list[i] C_sum L_list[i] L_list i C_cost += 10 C_cost 10 if min(A_sum, B_sum, C_sum) == 0: continue

     min(A_sum, B_sum, C_sum) == 0 min(A_sum, B_sum, C_sum) min A_sum B_sum C_sum 0 ans = min(ans, abs(A - A_sum)+A_cost + abs(B - B_sum)+B_cost + abs(C - C_sum)+C_cost) ans min(ans, abs(A - A_sum)+A_cost + abs(B - B_sum)+B_cost + abs(C - C_sum)+C_cost) min ans abs(A - A_sum)+A_cost + abs(B - B_sum)+B_cost + abs(C - C_sum)+C_cost abs(A - A_sum)+A_cost + abs(B - B_sum)+B_cost + abs(C - C_sum) abs(A - A_sum)+A_cost + abs(B - B_sum)+B_cost abs(A - A_sum)+A_cost + abs(B - B_sum) abs(A - A_sum)+A_cost abs(A - A_sum) abs A - A_sum A A_sum A_cost abs(B - B_sum) abs B - B_sum B B_sum B_cost abs(C - C_sum) abs C - C_sum C C_sum C_cost print(ans) print ans C_sum = 0 0 C_sum Target = itertools.product([0, 1, 2, 3], repeat=N) itertools.product([0, 1, 2, 3], repeat=N) Target INF = 10 ** 9 10 ** 9 INF ans = INF INF ans B, C = map(int, input().split()) map(int, input().split()) B B_cost += 10 10 B_cost N, A, B, C = map(int, input().split()) map(int, input().split()) N C_cost += 10 10 C_cost ans = min(ans, abs(A - A_sum)+A_cost + abs(B - B_sum)+B_cost + abs(C - C_sum)+C_cost) min(ans, abs(A - A_sum)+A_cost + abs(B - B_sum)+B_cost + abs(C - C_sum)+C_cost) ans A_sum += L_list[i] L_list[i] A_sum B_sum = 0 0 B_sum C = map(int, input().split()) map(int, input().split()) C B_sum += L_list[i] L_list[i] B_sum A_sum += L_list[i] L_list[i] A_sum A_cost = 0 0 A_cost C_sum += L_list[i] L_list[i] C_sum A_cost += 10 10 A_cost C_cost = 0 0 C_cost A_sum = 0 0 A_sum L_list = [int(input()) for i in range(N)] [int(input()) for i in range(N)] L_list B_cost = 0 0 B_cost C_sum += L_list[i] L_list[i] C_sum A, B, C = map(int, input().split()) map(int, input().split()) A B_sum += L_list[i] L_list[i] B_sum
N, A, B, C = map(int, input().split())
L_list = [int(input()) for i in range(N)]

import itertools

Target = itertools.product([0, 1, 2, 3], repeat=N)

INF = 10 ** 9
#Target = [(1,2,2,2,3)]
ans = INF
for T in Target:
    A_sum = 0
    B_sum = 0
    C_sum = 0
    A_cost = 0
    B_cost = 0
    C_cost = 0
    for i in range(N):
        if T[i] == 0: continue
        if T[i] == 1:
            if A_sum == 0:
                A_sum += L_list[i]
            else:
                A_sum += L_list[i]
                A_cost += 10
        if T[i] == 2:
            if B_sum == 0:
                B_sum += L_list[i]
            else:
                B_sum += L_list[i]
                B_cost += 10
        if T[i] == 3:
            if C_sum == 0:
                C_sum += L_list[i]
            else:
                C_sum += L_list[i]
                C_cost += 10

    if min(A_sum, B_sum, C_sum) == 0: continue

    ans = min(ans, abs(A - A_sum)+A_cost + abs(B - B_sum)+B_cost + abs(C - C_sum)+C_cost)
print(ans)
