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

def dfs(i, a, b, c):
    if i == N:
        if a and b and c:
            return abs(a - A) + abs(b - B) + abs(c - C)
        else:
            return 10 ** 9 + 7
    else:
        ret1 = dfs(i + 1, a + l[i], b, c) + 10
        ret2 = dfs(i + 1, a, b + l[i], c) + 10
        ret3 = dfs(i + 1, a, b, c + l[i]) + 10
        ret4 = dfs(i + 1, a, b, c)
        ret = min(ret1, ret2, ret3, ret4)
        return ret
    
ans = dfs(0, 0, 0, 0)
print(ans - 30) N, A, B, C = list(map(int,input().split())) N list(map(int,input().split())) list 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 and b and c:
            return abs(a - A) + abs(b - B) + abs(c - C)
        else:
            return 10 ** 9 + 7
    else:
        ret1 = dfs(i + 1, a + l[i], b, c) + 10
        ret2 = dfs(i + 1, a, b + l[i], c) + 10
        ret3 = dfs(i + 1, a, b, c + l[i]) + 10
        ret4 = dfs(i + 1, a, b, c)
        ret = min(ret1, ret2, ret3, ret4)
        return ret
     dfs if i == N:
        if a and b and c:
            return abs(a - A) + abs(b - B) + abs(c - C)
        else:
            return 10 ** 9 + 7
    else:
        ret1 = dfs(i + 1, a + l[i], b, c) + 10
        ret2 = dfs(i + 1, a, b + l[i], c) + 10
        ret3 = dfs(i + 1, a, b, c + l[i]) + 10
        ret4 = dfs(i + 1, a, b, c)
        ret = min(ret1, ret2, ret3, ret4)
        return ret
     i == N i N if a and b and c:
            return abs(a - A) + abs(b - B) + abs(c - C)
        else:
            return 10 ** 9 + 7
     a and b and c a and b a b c return abs(a - A) + abs(b - B) + abs(c - C) 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 return 10 ** 9 + 7 10 ** 9 + 7 10 ** 9 10 9 7 ret1 = dfs(i + 1, a + l[i], b, c) + 10 ret1 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 ret2 = dfs(i + 1, a, b + l[i], c) + 10 ret2 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 ret3 = dfs(i + 1, a, b, c + l[i]) + 10 ret3 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 ret4 = dfs(i + 1, a, b, c) ret4 dfs(i + 1, a, b, c) dfs i + 1 i 1 a b c ret = min(ret1, ret2, ret3, ret4) ret min(ret1, ret2, ret3, ret4) min ret1 ret2 ret3 ret4 return ret ret i i a a b b c c ans = dfs(0, 0, 0, 0) ans dfs(0, 0, 0, 0) dfs 0 0 0 0 print(ans - 30) print ans - 30 ans 30 N, A, B, C = list(map(int,input().split())) list(map(int,input().split())) N l = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] l ans = dfs(0, 0, 0, 0) dfs(0, 0, 0, 0) ans B, C = list(map(int,input().split())) list(map(int,input().split())) B C = list(map(int,input().split())) list(map(int,input().split())) C def dfs(i, a, b, c):
    if i == N:
        if a and b and c:
            return abs(a - A) + abs(b - B) + abs(c - C)
        else:
            return 10 ** 9 + 7
    else:
        ret1 = dfs(i + 1, a + l[i], b, c) + 10
        ret2 = dfs(i + 1, a, b + l[i], c) + 10
        ret3 = dfs(i + 1, a, b, c + l[i]) + 10
        ret4 = dfs(i + 1, a, b, c)
        ret = min(ret1, ret2, ret3, ret4)
        return ret
     def dfs(i, a, b, c):
    if i == N:
        if a and b and c:
            return abs(a - A) + abs(b - B) + abs(c - C)
        else:
            return 10 ** 9 + 7
    else:
        ret1 = dfs(i + 1, a + l[i], b, c) + 10
        ret2 = dfs(i + 1, a, b + l[i], c) + 10
        ret3 = dfs(i + 1, a, b, c + l[i]) + 10
        ret4 = dfs(i + 1, a, b, c)
        ret = min(ret1, ret2, ret3, ret4)
        return ret
     dfs A, B, C = list(map(int,input().split())) list(map(int,input().split())) A
N, A, B, C = list(map(int,input().split()))
l = [int(input()) for _ in range(N)]

def dfs(i, a, b, c):
    if i == N:
        if a and b and c:
            return abs(a - A) + abs(b - B) + abs(c - C)
        else:
            return 10 ** 9 + 7
    else:
        ret1 = dfs(i + 1, a + l[i], b, c) + 10
        ret2 = dfs(i + 1, a, b + l[i], c) + 10
        ret3 = dfs(i + 1, a, b, c + l[i]) + 10
        ret4 = dfs(i + 1, a, b, c)
        ret = min(ret1, ret2, ret3, ret4)
        return ret
    
ans = dfs(0, 0, 0, 0)
print(ans - 30)