def dfs(wants, remains):
    if len(wants) == 0:
        return 0
    for w in wants:
        if w in remains:
            new_wants = wants[:]
            new_wants.remove(w)
            new_remains = remains[:]
            new_remains.remove(w)
            return dfs(new_wants, new_remains)

    min_cost = float("inf")
    if len(wants) < len(remains):  # 合成
        for i in range(1, len(remains)):
            min_cost = min(min_cost, 10+dfs(wants, [remains[0] + remains[i]] + remains[1:i] + remains[i+1:] ))

    for i in range(len(wants)): # 延長
        min_cost = min(min_cost, abs(wants[i]-remains[0]) + dfs(wants[:i] + wants[i+1:], remains[1:]))
    return min_cost

N, A, B, C = map(int, input().split())
ls = []
for _ in range(N):
    ls.append(int(input()))

wants = [A, B, C]
print(dfs(wants, ls))