N, A, B, C = map(int,input().split())
INF = float('inf')
L = []
for _ in range(N):
    L.append(int(input()))

def dfs(i, cnt, a, b, c):
    if i == N:
        if a == 0 or b == 0 or c == 0:
            return INF
        return abs(a - A) + abs(b - B) + abs(c - C) + 10 * cnt
    MP = INF
    if a == 0:
        MP = min(MP, dfs(i+1, cnt, a+L[i], b, c))
    else:
        MP = min(MP, dfs(i+1, cnt+1, a+L[i], b, c))
    if b == 0:
        MP = min(MP, dfs(i+1, cnt, a, b+L[i], c))
    else:
        MP = min(MP, dfs(i+1, cnt+1, a, b+L[i], c))
    if c == 0:
        MP = min(MP, dfs(i+1, cnt, a, b, c+L[i]))
    else:
        MP = min(MP, dfs(i+1, cnt+1, a, b, c+L[i]))
    MP = min(MP, dfs(i+1, cnt, a, b, c))
    
    return MP

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

def dfs(i, cnt, a, b, c):
    if i == N:
        if a == 0 or b == 0 or c == 0:
            return INF
        return abs(a - A) + abs(b - B) + abs(c - C) + 10 * cnt
    MP = INF
    if a == 0:
        MP = min(MP, dfs(i+1, cnt, a+L[i], b, c))
    else:
        MP = min(MP, dfs(i+1, cnt+1, a+L[i], b, c))
    if b == 0:
        MP = min(MP, dfs(i+1, cnt, a, b+L[i], c))
    else:
        MP = min(MP, dfs(i+1, cnt+1, a, b+L[i], c))
    if c == 0:
        MP = min(MP, dfs(i+1, cnt, a, b, c+L[i]))
    else:
        MP = min(MP, dfs(i+1, cnt+1, a, b, c+L[i]))
    MP = min(MP, dfs(i+1, cnt, a, b, c))
    
    return MP

print(dfs(0, 0, 0, 0, 0))