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

def DFS(cnt, a, b, c):
    if cnt == N:
        # print(cnt, a, b, c)
        if a == 0 or b == 0 or c == 0:
            return 10 ** 10
        return abs(A-a) + abs(B-b) + abs(C-c) - 30

    r1 = DFS(cnt+1, a, b, c)
    r2 = DFS(cnt+1, a+l[cnt], b, c) + 10
    r3 = DFS(cnt+1, a, b+l[cnt], c) + 10
    r4 = DFS(cnt+1, a, b, c+l[cnt]) + 10
    return min(r1, r2, r3, r4)

print(DFS(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 l = [int(input()) for _ in range(N)] l [int(input()) for _ in range(N)] def DFS(cnt, a, b, c):
    if cnt == N:
        # print(cnt, a, b, c)
        if a == 0 or b == 0 or c == 0:
            return 10 ** 10
        return abs(A-a) + abs(B-b) + abs(C-c) - 30

    r1 = DFS(cnt+1, a, b, c)
    r2 = DFS(cnt+1, a+l[cnt], b, c) + 10
    r3 = DFS(cnt+1, a, b+l[cnt], c) + 10
    r4 = DFS(cnt+1, a, b, c+l[cnt]) + 10
    return min(r1, r2, r3, r4) DFS if cnt == N:
        # print(cnt, a, b, c)
        if a == 0 or b == 0 or c == 0:
            return 10 ** 10
        return abs(A-a) + abs(B-b) + abs(C-c) - 30

     cnt == N cnt N if a == 0 or b == 0 or c == 0:
            return 10 ** 10
         a == 0 or b == 0 or c == 0 a == 0 or b == 0 a == 0 a 0 b == 0 b 0 c == 0 c 0 return 10 ** 10 10 ** 10 10 10 return abs(A-a) + abs(B-b) + abs(C-c) - 30 abs(A-a) + abs(B-b) + abs(C-c) - 30 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 30 r1 = DFS(cnt+1, a, b, c) r1 DFS(cnt+1, a, b, c) DFS cnt+1 cnt 1 a b c r2 = DFS(cnt+1, a+l[cnt], b, c) + 10 r2 DFS(cnt+1, a+l[cnt], b, c) + 10 DFS(cnt+1, a+l[cnt], b, c) DFS cnt+1 cnt 1 a+l[cnt] a l[cnt] l cnt b c 10 r3 = DFS(cnt+1, a, b+l[cnt], c) + 10 r3 DFS(cnt+1, a, b+l[cnt], c) + 10 DFS(cnt+1, a, b+l[cnt], c) DFS cnt+1 cnt 1 a b+l[cnt] b l[cnt] l cnt c 10 r4 = DFS(cnt+1, a, b, c+l[cnt]) + 10 r4 DFS(cnt+1, a, b, c+l[cnt]) + 10 DFS(cnt+1, a, b, c+l[cnt]) DFS cnt+1 cnt 1 a b c+l[cnt] c l[cnt] l cnt 10 return min(r1, r2, r3, r4) min(r1, r2, r3, r4) min r1 r2 r3 r4 cnt cnt a a b b c c print(DFS(0, 0, 0, 0)) print DFS(0, 0, 0, 0) DFS 0 0 0 0 B, C = map(int, input().split()) map(int, input().split()) B A, B, C = map(int, input().split()) map(int, input().split()) A l = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] l N, A, B, C = map(int, input().split()) map(int, input().split()) N def DFS(cnt, a, b, c):
    if cnt == N:
        # print(cnt, a, b, c)
        if a == 0 or b == 0 or c == 0:
            return 10 ** 10
        return abs(A-a) + abs(B-b) + abs(C-c) - 30

    r1 = DFS(cnt+1, a, b, c)
    r2 = DFS(cnt+1, a+l[cnt], b, c) + 10
    r3 = DFS(cnt+1, a, b+l[cnt], c) + 10
    r4 = DFS(cnt+1, a, b, c+l[cnt]) + 10
    return min(r1, r2, r3, r4) def DFS(cnt, a, b, c):
    if cnt == N:
        # print(cnt, a, b, c)
        if a == 0 or b == 0 or c == 0:
            return 10 ** 10
        return abs(A-a) + abs(B-b) + abs(C-c) - 30

    r1 = DFS(cnt+1, a, b, c)
    r2 = DFS(cnt+1, a+l[cnt], b, c) + 10
    r3 = DFS(cnt+1, a, b+l[cnt], c) + 10
    r4 = DFS(cnt+1, a, b, c+l[cnt]) + 10
    return min(r1, r2, r3, r4) DFS C = map(int, input().split()) map(int, input().split()) C
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

def DFS(cnt, a, b, c):
    if cnt == N:
        # print(cnt, a, b, c)
        if a == 0 or b == 0 or c == 0:
            return 10 ** 10
        return abs(A-a) + abs(B-b) + abs(C-c) - 30

    r1 = DFS(cnt+1, a, b, c)
    r2 = DFS(cnt+1, a+l[cnt], b, c) + 10
    r3 = DFS(cnt+1, a, b+l[cnt], c) + 10
    r4 = DFS(cnt+1, a, b, c+l[cnt]) + 10
    return min(r1, r2, r3, r4)

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