N, A, B, C = map(int, input().split())

L = [int(input()) for _ in range(N)]

ans = []
def dfs(idx, a, b, c, mp10):
    if idx==N:
        if a and b and c:
            ans.append(abs(A-a)+abs(B-b)+abs(C-c)+mp10*10)
    else:
        dfs(idx+1, a, b, c, mp10)
        dfs(idx+1, a+L[idx], b, c, mp10+1)
        dfs(idx+1, a, b+L[idx], c, mp10+1)
        dfs(idx+1, a, b, c+L[idx], mp10+1)

dfs(0, 0, 0, 0, -3)

print(min(ans)) 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)] ans = [] ans [] def dfs(idx, a, b, c, mp10):
    if idx==N:
        if a and b and c:
            ans.append(abs(A-a)+abs(B-b)+abs(C-c)+mp10*10)
    else:
        dfs(idx+1, a, b, c, mp10)
        dfs(idx+1, a+L[idx], b, c, mp10+1)
        dfs(idx+1, a, b+L[idx], c, mp10+1)
        dfs(idx+1, a, b, c+L[idx], mp10+1) dfs if idx==N:
        if a and b and c:
            ans.append(abs(A-a)+abs(B-b)+abs(C-c)+mp10*10)
    else:
        dfs(idx+1, a, b, c, mp10)
        dfs(idx+1, a+L[idx], b, c, mp10+1)
        dfs(idx+1, a, b+L[idx], c, mp10+1)
        dfs(idx+1, a, b, c+L[idx], mp10+1) idx==N idx N if a and b and c:
            ans.append(abs(A-a)+abs(B-b)+abs(C-c)+mp10*10)
     a and b and c a and b a b c ans.append(abs(A-a)+abs(B-b)+abs(C-c)+mp10*10) ans.append ans append abs(A-a)+abs(B-b)+abs(C-c)+mp10*10 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 mp10*10 mp10 10 dfs(idx+1, a, b, c, mp10) dfs idx+1 idx 1 a b c mp10 dfs(idx+1, a+L[idx], b, c, mp10+1) dfs idx+1 idx 1 a+L[idx] a L[idx] L idx b c mp10+1 mp10 1 dfs(idx+1, a, b+L[idx], c, mp10+1) dfs idx+1 idx 1 a b+L[idx] b L[idx] L idx c mp10+1 mp10 1 dfs(idx+1, a, b, c+L[idx], mp10+1) dfs idx+1 idx 1 a b c+L[idx] c L[idx] L idx mp10+1 mp10 1 idx idx a a b b c c mp10 mp10 dfs(0, 0, 0, 0, -3) dfs 0 0 0 0 -3 print(min(ans)) print min(ans) min ans 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 C = map(int, input().split()) map(int, input().split()) C B, C = map(int, input().split()) map(int, input().split()) B ans = [] [] ans def dfs(idx, a, b, c, mp10):
    if idx==N:
        if a and b and c:
            ans.append(abs(A-a)+abs(B-b)+abs(C-c)+mp10*10)
    else:
        dfs(idx+1, a, b, c, mp10)
        dfs(idx+1, a+L[idx], b, c, mp10+1)
        dfs(idx+1, a, b+L[idx], c, mp10+1)
        dfs(idx+1, a, b, c+L[idx], mp10+1) def dfs(idx, a, b, c, mp10):
    if idx==N:
        if a and b and c:
            ans.append(abs(A-a)+abs(B-b)+abs(C-c)+mp10*10)
    else:
        dfs(idx+1, a, b, c, mp10)
        dfs(idx+1, a+L[idx], b, c, mp10+1)
        dfs(idx+1, a, b+L[idx], c, mp10+1)
        dfs(idx+1, a, b, c+L[idx], mp10+1) dfs
N, A, B, C = map(int, input().split())

L = [int(input()) for _ in range(N)]

ans = []
def dfs(idx, a, b, c, mp10):
    if idx==N:
        if a and b and c:
            ans.append(abs(A-a)+abs(B-b)+abs(C-c)+mp10*10)
    else:
        dfs(idx+1, a, b, c, mp10)
        dfs(idx+1, a+L[idx], b, c, mp10+1)
        dfs(idx+1, a, b+L[idx], c, mp10+1)
        dfs(idx+1, a, b, c+L[idx], mp10+1)

dfs(0, 0, 0, 0, -3)

print(min(ans))