N, A, B, C = [int(a) for a in input().split(" ")]
ls = [int(input()) for i in range(N)]

def solve(ls):
    n = len(ls)
    ans = float("inf")
    for i in range(n):
        for j in range(n):
            for k in range(n):
                if i!=j and j!=k and i!=k:
                    tmp = abs(ls[i]-A)+abs(ls[j]-B)+abs(ls[k]-C)
                    ans = min(ans, tmp)
    return ans

def dfs(ls):
    n = len(ls)
    if n < 3:
        return float("inf")
    ans = solve(ls)
    for i in range(n-1):
        for j in range(i+1,n):
            ls2 = ls[:i]+ls[i+1:]
            ls2[j-1] = ls[i]+ls[j]
            ans = min(ans, 10+dfs(ls2))
    return ans

print(dfs(ls))