N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]

def dist(l, A, B, C):
    min_dist = 3000
    for i in range(len(l)):
        for j in range(len(l)):
            for k in range(len(l)):
                if i != j and j != k:
                    dist = abs(A - l[i]) + abs(B - l[j]) + abs(C - l[k])
                    if dist < min_dist:
                        min_dist = dist
    return min_dist

def dfs(l, depth):
    node_score = depth * 10 + dist(l, A, B, C)
    if len(l) == 3:
        return node_score
    for i in range(len(l)):
        for j in range(i+1, len(l)):
            child_l = l[:i] + l[i+1:j] + l[j+1:] + [l[i] + l[j]]
            child_score = dfs(child_l, depth + 1)
            if child_score < node_score:
                node_score = child_score
    return node_score

print(dfs(l, 0))