import itertools as it

N, A, B, C = list(map(lambda I: int(I), input().split(' ')))  # C < B < A
l_list = []
for _ in range(N):
    l_list.append(int(input()))

MP = 0
target_bamboo_dict = {'A':A, 'B':B, 'C':C}
extract_num = 0
flags = {'A': False, 'B': False, 'C': False}
while not flags['A'] or not flags['B'] or not flags['C']:
    length = 0
    for b in flags.values():
        if not b:
            length += 1
    if extract_num > len(l_list) or length == len(l_list):
        for key, v_bool in flags.items():
            if not v_bool:
                min_diff = 10000
                used_bamboo = 0
                for bamboo in l_list:
                    diff = abs(target_bamboo_dict[key] - bamboo)

                    if min_diff > diff:
                        min_diff = diff
                        used_bamboo = bamboo
                MP += min_diff
                l_list.remove(bamboo)
                flags[key] = True

    else:
        # print('n:', extract_num)
        made_bamboos_before_sum = list(it.combinations(l_list, extract_num+1))
        made_bamboos = map(lambda bs: sum(bs), made_bamboos_before_sum)
        min_diff_l = {'A':10000, 'B':10000, 'C':10000}
        min_diff_l_index = {'A': 0, 'B': 0, 'C': 0}

        for i, made_bamboo in enumerate(made_bamboos):
            diff_l = {'A':abs(made_bamboo-A), 'B':abs(made_bamboo-B), 'C':abs(made_bamboo-C)}
            for key, value in diff_l.items():
                if min_diff_l[key] > value:
                    min_diff_l[key] = value
                    min_diff_l_index[key] = i
        # print(min_diff_l)
        min_of_min = 10000
        min_of_min_key = ''
        for min_key, min_value in min_diff_l.items():
            if not flags[min_key]:
                if min_of_min > min_value:
                    min_of_min = min_value
                    min_of_min_key = min_key

        if min_of_min <= 10:
            MP += extract_num * 10 + min_of_min
            flags[min_of_min_key] = True
            remove_bamboos = made_bamboos_before_sum[min_diff_l_index[min_of_min_key]]
            for remove_bamboo in remove_bamboos:
                l_list.remove(remove_bamboo)
        else:
            extract_num += 1


print(MP)

