
N,A,B,C = map(int, input().split())
bamboos = [int(input()) for _ in range(N)]
#print("---", bamboos)
INF = float("inf")
ans = INF
def solve(idx, cnt_merge, a, b, c):

    if idx == N:
        if min(a,b,c) > 0:
            return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt_merge-3)
        else:
            return INF

    pa = solve(idx+1, cnt_merge+1, a+bamboos[idx], b, c)
    pb = solve(idx+1, cnt_merge+1, a, b+bamboos[idx], c)
    pc = solve(idx+1, cnt_merge+1, a, b, c+bamboos[idx])
    pn = solve(idx+1, cnt_merge, a, b, c)
    return min(pa, pb, pc, pn)


print(solve(0,0,0,0,0)) N,A,B,C = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split A B C int(input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input bamboos = [int(input()) for _ in range(N)] bamboos [int(input()) for _ in range(N)] INF = float("inf") INF float("inf") float "inf" ans = INF ans INF def solve(idx, cnt_merge, a, b, c):

    if idx == N:
        if min(a,b,c) > 0:
            return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt_merge-3)
        else:
            return INF

    pa = solve(idx+1, cnt_merge+1, a+bamboos[idx], b, c)
    pb = solve(idx+1, cnt_merge+1, a, b+bamboos[idx], c)
    pc = solve(idx+1, cnt_merge+1, a, b, c+bamboos[idx])
    pn = solve(idx+1, cnt_merge, a, b, c)
    return min(pa, pb, pc, pn) solve if idx == N:
        if min(a,b,c) > 0:
            return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt_merge-3)
        else:
            return INF

     idx == N idx N if min(a,b,c) > 0:
            return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt_merge-3)
        else:
            return INF

     min(a,b,c) > 0 min(a,b,c) min a b c 0 return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt_merge-3) abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt_merge-3) abs(A - a) + abs(B - b) + abs(C - c) abs(A - a) + abs(B - b) abs(A - a) abs A - a A a abs(B - b) abs B - b B b abs(C - c) abs C - c C c 10 * (cnt_merge-3) 10 cnt_merge-3 cnt_merge 3 return INF INF pa = solve(idx+1, cnt_merge+1, a+bamboos[idx], b, c) pa solve(idx+1, cnt_merge+1, a+bamboos[idx], b, c) solve idx+1 idx 1 cnt_merge+1 cnt_merge 1 a+bamboos[idx] a bamboos[idx] bamboos idx b c pb = solve(idx+1, cnt_merge+1, a, b+bamboos[idx], c) pb solve(idx+1, cnt_merge+1, a, b+bamboos[idx], c) solve idx+1 idx 1 cnt_merge+1 cnt_merge 1 a b+bamboos[idx] b bamboos[idx] bamboos idx c pc = solve(idx+1, cnt_merge+1, a, b, c+bamboos[idx]) pc solve(idx+1, cnt_merge+1, a, b, c+bamboos[idx]) solve idx+1 idx 1 cnt_merge+1 cnt_merge 1 a b c+bamboos[idx] c bamboos[idx] bamboos idx pn = solve(idx+1, cnt_merge, a, b, c) pn solve(idx+1, cnt_merge, a, b, c) solve idx+1 idx 1 cnt_merge a b c return min(pa, pb, pc, pn) min(pa, pb, pc, pn) min pa pb pc pn idx idx cnt_merge cnt_merge a a b b c c print(solve(0,0,0,0,0)) print solve(0,0,0,0,0) solve 0 0 0 0 0 INF = float("inf") float("inf") INF N,A,B,C = map(int, input().split()) map(int, input().split()) N A,B,C = map(int, input().split()) map(int, input().split()) A def solve(idx, cnt_merge, a, b, c):

    if idx == N:
        if min(a,b,c) > 0:
            return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt_merge-3)
        else:
            return INF

    pa = solve(idx+1, cnt_merge+1, a+bamboos[idx], b, c)
    pb = solve(idx+1, cnt_merge+1, a, b+bamboos[idx], c)
    pc = solve(idx+1, cnt_merge+1, a, b, c+bamboos[idx])
    pn = solve(idx+1, cnt_merge, a, b, c)
    return min(pa, pb, pc, pn) def solve(idx, cnt_merge, a, b, c):

    if idx == N:
        if min(a,b,c) > 0:
            return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt_merge-3)
        else:
            return INF

    pa = solve(idx+1, cnt_merge+1, a+bamboos[idx], b, c)
    pb = solve(idx+1, cnt_merge+1, a, b+bamboos[idx], c)
    pc = solve(idx+1, cnt_merge+1, a, b, c+bamboos[idx])
    pn = solve(idx+1, cnt_merge, a, b, c)
    return min(pa, pb, pc, pn) solve B,C = map(int, input().split()) map(int, input().split()) B C = map(int, input().split()) map(int, input().split()) C bamboos = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] bamboos ans = INF INF ans

N,A,B,C = map(int, input().split())
bamboos = [int(input()) for _ in range(N)]
#print("---", bamboos)
INF = float("inf")
ans = INF
def solve(idx, cnt_merge, a, b, c):

    if idx == N:
        if min(a,b,c) > 0:
            return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt_merge-3)
        else:
            return INF

    pa = solve(idx+1, cnt_merge+1, a+bamboos[idx], b, c)
    pb = solve(idx+1, cnt_merge+1, a, b+bamboos[idx], c)
    pc = solve(idx+1, cnt_merge+1, a, b, c+bamboos[idx])
    pn = solve(idx+1, cnt_merge, a, b, c)
    return min(pa, pb, pc, pn)


print(solve(0,0,0,0,0))