N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
def dfs(i, a, b, c):
    if i == N:
        if a == 0 or b == 0 or c == 0:
            return float('inf')
        else:
            return abs(A-a)+abs(B-b)+abs(C-c)-30
    four = dfs(i+1, a, b, c)
    one = dfs(i+1, a+l[i], b, c) + 10
    two = dfs(i+1, a, b+l[i], c) + 10
    three = dfs(i+1, a, b, c+l[i]) + 10
    return min(one, two, three, four)
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(i, a, b, c):
    if i == N:
        if a == 0 or b == 0 or c == 0:
            return float('inf')
        else:
            return abs(A-a)+abs(B-b)+abs(C-c)-30
    four = dfs(i+1, a, b, c)
    one = dfs(i+1, a+l[i], b, c) + 10
    two = dfs(i+1, a, b+l[i], c) + 10
    three = dfs(i+1, a, b, c+l[i]) + 10
    return min(one, two, three, four) dfs if i == N:
        if a == 0 or b == 0 or c == 0:
            return float('inf')
        else:
            return abs(A-a)+abs(B-b)+abs(C-c)-30
     i == N i N if a == 0 or b == 0 or c == 0:
            return float('inf')
        else:
            return abs(A-a)+abs(B-b)+abs(C-c)-30
     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 float('inf') float('inf') float 'inf' 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 four = dfs(i+1, a, b, c) four dfs(i+1, a, b, c) dfs i+1 i 1 a b c one = dfs(i+1, a+l[i], b, c) + 10 one dfs(i+1, a+l[i], b, c) + 10 dfs(i+1, a+l[i], b, c) dfs i+1 i 1 a+l[i] a l[i] l i b c 10 two = dfs(i+1, a, b+l[i], c) + 10 two dfs(i+1, a, b+l[i], c) + 10 dfs(i+1, a, b+l[i], c) dfs i+1 i 1 a b+l[i] b l[i] l i c 10 three = dfs(i+1, a, b, c+l[i]) + 10 three dfs(i+1, a, b, c+l[i]) + 10 dfs(i+1, a, b, c+l[i]) dfs i+1 i 1 a b c+l[i] c l[i] l i 10 return min(one, two, three, four) min(one, two, three, four) min one two three four i i a a b b c c print(dfs(0, 0, 0, 0)) print dfs(0, 0, 0, 0) dfs 0 0 0 0 def dfs(i, a, b, c):
    if i == N:
        if a == 0 or b == 0 or c == 0:
            return float('inf')
        else:
            return abs(A-a)+abs(B-b)+abs(C-c)-30
    four = dfs(i+1, a, b, c)
    one = dfs(i+1, a+l[i], b, c) + 10
    two = dfs(i+1, a, b+l[i], c) + 10
    three = dfs(i+1, a, b, c+l[i]) + 10
    return min(one, two, three, four) def dfs(i, a, b, c):
    if i == N:
        if a == 0 or b == 0 or c == 0:
            return float('inf')
        else:
            return abs(A-a)+abs(B-b)+abs(C-c)-30
    four = dfs(i+1, a, b, c)
    one = dfs(i+1, a+l[i], b, c) + 10
    two = dfs(i+1, a, b+l[i], c) + 10
    three = dfs(i+1, a, b, c+l[i]) + 10
    return min(one, two, three, four) dfs A, B, C = map(int, input().split()) map(int, input().split()) A C = map(int, input().split()) map(int, input().split()) C 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 B, C = map(int, input().split()) map(int, input().split()) B
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
def dfs(i, a, b, c):
    if i == N:
        if a == 0 or b == 0 or c == 0:
            return float('inf')
        else:
            return abs(A-a)+abs(B-b)+abs(C-c)-30
    four = dfs(i+1, a, b, c)
    one = dfs(i+1, a+l[i], b, c) + 10
    two = dfs(i+1, a, b+l[i], c) + 10
    three = dfs(i+1, a, b, c+l[i]) + 10
    return min(one, two, three, four)
print(dfs(0, 0, 0, 0))