import sys

from itertools import combinations





fin = sys.stdin.readline

N, A, B, C = [int(elem) for elem in fin().split()]

l_list = sorted([int(fin()) for _ in range(N)], reverse=True)



min_mp = float('inf')

for num_conc_A in range(1, N - 1):

    # mp = 0

    rest_indices = set(range(N))

    for A_indices in combinations(rest_indices, num_conc_A):

        mp_A = 10 * (num_conc_A - 1) + abs(sum(l_list[i] for i in A_indices) - A)

        rest_indices -= set(A_indices)

        for num_conc_B in range(1, N - num_conc_A):

            for B_indices in combinations(rest_indices, num_conc_B):

                mp_B = 10 * (num_conc_B - 1) + abs(sum(l_list[i] for i in B_indices) - B)

                rest_indices -= set(B_indices)

                for num_conc_C in range(1, N - num_conc_A - num_conc_B + 1):

                    for C_indices in combinations(rest_indices, num_conc_C):

                        mp_C = 10 * (num_conc_C - 1) + abs(sum(l_list[i] for i in C_indices) - C)

                        min_mp = min(min_mp, mp_A + mp_B + mp_C)

                rest_indices.update(set(B_indices))

        rest_indices.update(set(A_indices))

print(min_mp)
import sys

from itertools import combinations, product





fin = sys.stdin.readline

N, A, B, C = [int(elem) for elem in fin().split()]

l_list = [int(fin()) for _ in range(N)]



min_mp = float('inf')

for flags in product(list(range(4)), repeat=N):

    powers = [0] * 3

    num_items = [0] * 3

    for l, flag in zip(l_list, flags):

        if flag == 3:

            continue

        powers[flag] += l

        num_items[flag] += 1

    if not all(powers):

        continue

    mp = sum(

        abs(power - necessary_power) 

        for power, necessary_power in zip(powers, (A, B, C))

        ) + 10 * (sum(num_items) - 3)

    min_mp = min(mp, min_mp)

print(min_mp)
import sys
from itertools import combinations

fin = sys.stdin.readline
N, A, B, C = [int(elem) for elem in fin().split()]
l_list = sorted([int(fin()) for _ in range(N)], reverse=True)
min_mp = float("inf")
for num_conc_A in range(1, N - 1):
    # mp = 0
    rest_indices = set(range(N))
    for A_indices in combinations(rest_indices, num_conc_A):
        mp_A = 10 * (num_conc_A - 1) + abs(sum(l_list[i] for i in A_indices) - A)
        rest_indices -= set(A_indices)
        for num_conc_B in range(1, N - num_conc_A):
            for B_indices in combinations(rest_indices, num_conc_B):
                mp_B = 10 * (num_conc_B - 1) + abs(
                    sum(l_list[i] for i in B_indices) - B
                )
                rest_indices -= set(B_indices)
                for num_conc_C in range(1, N - num_conc_A - num_conc_B + 1):
                    for C_indices in combinations(rest_indices, num_conc_C):
                        mp_C = 10 * (num_conc_C - 1) + abs(
                            sum(l_list[i] for i in C_indices) - C
                        )
                        min_mp = min(min_mp, mp_A + mp_B + mp_C)
                rest_indices.update(set(B_indices))
        rest_indices.update(set(A_indices))
print(min_mp)

import sys
from itertools import combinations, product

fin = sys.stdin.readline
N, A, B, C = [int(elem) for elem in fin().split()]
l_list = [int(fin()) for _ in range(N)]
min_mp = float("inf")
for flags in product(list(range(4)), repeat=N):
    powers = [0] * 3
    num_items = [0] * 3
    for l, flag in zip(l_list, flags):
        if flag == 3:
            continue
        powers[flag] += l
        num_items[flag] += 1
    if not all(powers):
        continue
    mp = sum(
        abs(power - necessary_power)
        for power, necessary_power in zip(powers, (A, B, C))
    ) + 10 * (sum(num_items) - 3)
    min_mp = min(mp, min_mp)
print(min_mp)

-from itertools import combinations +from itertools import combinations, product -l_list = sorted([int(fin()) for _ in range(N)], reverse=True) +l_list = [int(fin()) for _ in range(N)] -for num_conc_A in range(1, N - 1): -    # mp = 0 -    rest_indices = set(range(N)) -    for A_indices in combinations(rest_indices, num_conc_A): -        mp_A = 10 * (num_conc_A - 1) + abs(sum(l_list[i] for i in A_indices) - A) -        rest_indices -= set(A_indices) -        for num_conc_B in range(1, N - num_conc_A): -            for B_indices in combinations(rest_indices, num_conc_B): -                mp_B = 10 * (num_conc_B - 1) + abs( -                    sum(l_list[i] for i in B_indices) - B -                ) -                rest_indices -= set(B_indices) -                for num_conc_C in range(1, N - num_conc_A - num_conc_B + 1): -                    for C_indices in combinations(rest_indices, num_conc_C): -                        mp_C = 10 * (num_conc_C - 1) + abs( -                            sum(l_list[i] for i in C_indices) - C -                        ) -                        min_mp = min(min_mp, mp_A + mp_B + mp_C) -                rest_indices.update(set(B_indices)) -        rest_indices.update(set(A_indices)) +for flags in product(list(range(4)), repeat=N): +    powers = [0] * 3 +    num_items = [0] * 3 +    for l, flag in zip(l_list, flags): +        if flag == 3: +            continue +        powers[flag] += l +        num_items[flag] += 1 +    if not all(powers): +        continue +    mp = sum( +        abs(power - necessary_power) +        for power, necessary_power in zip(powers, (A, B, C)) +    ) + 10 * (sum(num_items) - 3) +    min_mp = min(mp, min_mp)