
import itertools
import math
import copy

N, A, B, C = map(int, input().rstrip().split())


pattern = [list(itertools.combinations(range(x), 3)) for x in range(3, N+1)]

def stretch_shortening(sticks, A, B, C):
    sticks = sorted(sticks)
    min_cost = 1e10
    
    for i1, i2, i3 in pattern[len(sticks) - 3]:
        cost = abs(sticks[i1] - A) + abs(sticks[i2] - B) + abs(sticks[i3] - C)
        if min_cost > cost:
            min_cost = cost
    return min_cost

def connect(sticks, A, B, C):
    
    min_cost = stretch_shortening(sticks, A, B, C) + (N - len(sticks)) * 10
    
    if len(sticks) <= 3:
        return min_cost
    
    for i1, i2 in itertools.combinations(range(len(sticks)), 2):
        copied_sticks = copy.copy(sticks)
        copied_sticks[i1] += copied_sticks[i2]
        copied_sticks.pop(i2)
        min_cost_connect = connect(copied_sticks, A, B, C)
        if min_cost_connect < min_cost:
            min_cost = min_cost_connect
    
    return min_cost

sticks = []
for _ in range(N):
    sticks.append(int(input()))

min_cost = connect(sticks, C, B, A)
#min_cost = stretch_shortening(sticks, A, B, C)
#print(pattern)

print(min_cost)

