nums = list(map(int, input().split()))
N, A, B, C = nums[0], nums[1], nums[2], nums[3]
ls = [0 for _ in range(N)]
from itertools import combinations
from copy import deepcopy as copy
for i in range(N):
    ls[i] = int(input())

def solve(arr):
    return_val = 100000000000000000
    sorted_arr = sorted(arr)[::-1]
    for pair in list(combinations(range(len(arr)), 3)):
        val = abs(A-sorted_arr[pair[0]]) + abs(B-sorted_arr[pair[1]]) + abs(C-sorted_arr[pair[2]])
        if val < return_val:
            return_val = val

    if return_val == 0:
        return return_val
    if len(arr) > 3:
        for pair in list(combinations(range(len(arr)), 2)):
            first, second = pair[0], pair[1]
            copy_arr = copy(arr)
            tmp = copy_arr[first]
            del copy_arr[first]
            copy_arr[second-1] += tmp
            val = solve(copy_arr) + 10
            if val < return_val:
                return_val = val
    return return_val

print(solve(ls))
