N, A,B,C = map(int, input().split())
l = sorted([int(input()) for _ in range(N)])[-1::-1]

INF = 1e+10

def DFS(depth, current_a, current_b, current_c):
    if depth == N:
        if min(current_a, current_b, current_c) > 0:
            return abs(current_a - A) + abs(current_b - B) + abs(current_c - C) -30
        else:
            return INF
    
    ret0 = DFS(depth+1, current_a, current_b, current_c)
    ret1 = DFS(depth+1, current_a + l[depth], current_b, current_c)
    ret2 = DFS(depth+1, current_a , current_b+ l[depth], current_c)
    ret3 = DFS(depth+1, current_a, current_b, current_c + l[depth])
    
    return min(ret0, ret1, ret2, ret3)

print(DFS(0, 0, 0, 0))