# coding: utf-8

list = [int(i) for i in input().rstrip().split(" ")]

matsu_count = list[0]
require = sorted(list[1:])

matsu_list = sorted([int(input().rstrip()) for i in range(matsu_count)])

def get_mp(matsu:list):
    ans = 0
    for i in range(3):
        ans += abs(matsu[i] - require[i])
    return ans

def get_ans(matsu:list):
    if len(matsu) == 3:
        return get_mp(matsu)
    ans = 80000
    for i in range(len(matsu) - 3 + 1):
        ans = min(ans, get_mp(matsu[i:]))
    for i in range(len(matsu)):
        for j in range(i + 1, len(matsu)):
            sub_matsu = []
            for k in range(len(matsu)):
                if k == i or k == j:
                    continue
                else:
                    sub_matsu.append(matsu[k])
            sub_matsu.append(matsu[i] + matsu[j])
            ans = min(ans, get_ans(sorted(sub_matsu)) + 10)


    return ans

ans = get_ans(matsu_list)
print(ans)

