N, A, B, C = map(int, input().split())
l = []
for i in range(N):
    l.append(int(input()))
    
def dfs(bamboo, a, b, c):
    if bamboo == N:
        if min(a, b, c) > 0:
            return abs(A-a) + abs(B-b) + abs(C-c) - 30
        else:
            return 10**10
    else:
        ans1 = dfs(bamboo+1, a, b, c)
        ans2 = dfs(bamboo+1, a+l[bamboo], b, c) + 10
        ans3 = dfs(bamboo+1, a, b+l[bamboo], c) + 10
        ans4 = dfs(bamboo+1, a, b, c+l[bamboo]) + 10
        return min(ans1, ans2, ans3, ans4)
        
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 l = [] l [] for i in range(N):
    l.append(int(input()))
     i range(N) range N l.append(int(input())) l.append l append int(input()) int input() input def dfs(bamboo, a, b, c):
    if bamboo == N:
        if min(a, b, c) > 0:
            return abs(A-a) + abs(B-b) + abs(C-c) - 30
        else:
            return 10**10
    else:
        ans1 = dfs(bamboo+1, a, b, c)
        ans2 = dfs(bamboo+1, a+l[bamboo], b, c) + 10
        ans3 = dfs(bamboo+1, a, b+l[bamboo], c) + 10
        ans4 = dfs(bamboo+1, a, b, c+l[bamboo]) + 10
        return min(ans1, ans2, ans3, ans4)
         dfs if bamboo == N:
        if min(a, b, c) > 0:
            return abs(A-a) + abs(B-b) + abs(C-c) - 30
        else:
            return 10**10
    else:
        ans1 = dfs(bamboo+1, a, b, c)
        ans2 = dfs(bamboo+1, a+l[bamboo], b, c) + 10
        ans3 = dfs(bamboo+1, a, b+l[bamboo], c) + 10
        ans4 = dfs(bamboo+1, a, b, c+l[bamboo]) + 10
        return min(ans1, ans2, ans3, ans4)
         bamboo == N bamboo N if min(a, b, c) > 0:
            return abs(A-a) + abs(B-b) + abs(C-c) - 30
        else:
            return 10**10
     min(a, b, c) > 0 min(a, b, c) min a b c 0 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 return 10**10 10**10 10 10 ans1 = dfs(bamboo+1, a, b, c) ans1 dfs(bamboo+1, a, b, c) dfs bamboo+1 bamboo 1 a b c ans2 = dfs(bamboo+1, a+l[bamboo], b, c) + 10 ans2 dfs(bamboo+1, a+l[bamboo], b, c) + 10 dfs(bamboo+1, a+l[bamboo], b, c) dfs bamboo+1 bamboo 1 a+l[bamboo] a l[bamboo] l bamboo b c 10 ans3 = dfs(bamboo+1, a, b+l[bamboo], c) + 10 ans3 dfs(bamboo+1, a, b+l[bamboo], c) + 10 dfs(bamboo+1, a, b+l[bamboo], c) dfs bamboo+1 bamboo 1 a b+l[bamboo] b l[bamboo] l bamboo c 10 ans4 = dfs(bamboo+1, a, b, c+l[bamboo]) + 10 ans4 dfs(bamboo+1, a, b, c+l[bamboo]) + 10 dfs(bamboo+1, a, b, c+l[bamboo]) dfs bamboo+1 bamboo 1 a b c+l[bamboo] c l[bamboo] l bamboo 10 return min(ans1, ans2, ans3, ans4) min(ans1, ans2, ans3, ans4) min ans1 ans2 ans3 ans4 bamboo bamboo a a b b c c print(dfs(0, 0, 0, 0)) print dfs(0, 0, 0, 0) dfs 0 0 0 0 C = map(int, input().split()) map(int, input().split()) C def dfs(bamboo, a, b, c):
    if bamboo == N:
        if min(a, b, c) > 0:
            return abs(A-a) + abs(B-b) + abs(C-c) - 30
        else:
            return 10**10
    else:
        ans1 = dfs(bamboo+1, a, b, c)
        ans2 = dfs(bamboo+1, a+l[bamboo], b, c) + 10
        ans3 = dfs(bamboo+1, a, b+l[bamboo], c) + 10
        ans4 = dfs(bamboo+1, a, b, c+l[bamboo]) + 10
        return min(ans1, ans2, ans3, ans4)
         def dfs(bamboo, a, b, c):
    if bamboo == N:
        if min(a, b, c) > 0:
            return abs(A-a) + abs(B-b) + abs(C-c) - 30
        else:
            return 10**10
    else:
        ans1 = dfs(bamboo+1, a, b, c)
        ans2 = dfs(bamboo+1, a+l[bamboo], b, c) + 10
        ans3 = dfs(bamboo+1, a, b+l[bamboo], c) + 10
        ans4 = dfs(bamboo+1, a, b, c+l[bamboo]) + 10
        return min(ans1, ans2, ans3, ans4)
         dfs A, B, C = map(int, input().split()) map(int, input().split()) A l = [] [] 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 = []
for i in range(N):
    l.append(int(input()))
    
def dfs(bamboo, a, b, c):
    if bamboo == N:
        if min(a, b, c) > 0:
            return abs(A-a) + abs(B-b) + abs(C-c) - 30
        else:
            return 10**10
    else:
        ans1 = dfs(bamboo+1, a, b, c)
        ans2 = dfs(bamboo+1, a+l[bamboo], b, c) + 10
        ans3 = dfs(bamboo+1, a, b+l[bamboo], c) + 10
        ans4 = dfs(bamboo+1, a, b, c+l[bamboo]) + 10
        return min(ans1, ans2, ans3, ans4)
        
print(dfs(0, 0, 0, 0))