import sys
sys.setrecursionlimit(10**7)
n,A,B,C = map(int,input().split())
L_ls = [int(input()) for _ in range(n)]

# dfs(i,a,b,c) := i番目の竹のまえの時点で、A用の長さがa, B用の長さがb, C用の長さがcだった時の、それ以降の分岐での最初コスト
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)
    
    Min = dfs(i+1,a,b,c)

    if a == 0:
        Min = min(Min,dfs(i+1,a+L_ls[i],b,c))
    else:
        Min = min(Min,dfs(i+1,a+L_ls[i],b,c)+10)
    
    if b == 0:
        Min = min(Min,dfs(i+1,a,b+L_ls[i],c))
    else:
        Min = min(Min,dfs(i+1,a,b+L_ls[i],c)+10)
    
    if c == 0:
        Min = min(Min,dfs(i+1,a,b,c+L_ls[i]))
    else:
        Min = min(Min,dfs(i+1,a,b,c+L_ls[i])+10)
    
    return Min
print(dfs(0,0,0,0)) import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 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_ls = [int(input()) for _ in range(n)] L_ls [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)
    
    Min = dfs(i+1,a,b,c)

    if a == 0:
        Min = min(Min,dfs(i+1,a+L_ls[i],b,c))
    else:
        Min = min(Min,dfs(i+1,a+L_ls[i],b,c)+10)
    
    if b == 0:
        Min = min(Min,dfs(i+1,a,b+L_ls[i],c))
    else:
        Min = min(Min,dfs(i+1,a,b+L_ls[i],c)+10)
    
    if c == 0:
        Min = min(Min,dfs(i+1,a,b,c+L_ls[i]))
    else:
        Min = min(Min,dfs(i+1,a,b,c+L_ls[i])+10)
    
    return Min 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)
    
     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)
    
     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) 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 Min = dfs(i+1,a,b,c) Min dfs(i+1,a,b,c) dfs i+1 i 1 a b c if a == 0:
        Min = min(Min,dfs(i+1,a+L_ls[i],b,c))
    else:
        Min = min(Min,dfs(i+1,a+L_ls[i],b,c)+10)
    
     a == 0 a 0 Min = min(Min,dfs(i+1,a+L_ls[i],b,c)) Min min(Min,dfs(i+1,a+L_ls[i],b,c)) min Min dfs(i+1,a+L_ls[i],b,c) dfs i+1 i 1 a+L_ls[i] a L_ls[i] L_ls i b c Min = min(Min,dfs(i+1,a+L_ls[i],b,c)+10) Min min(Min,dfs(i+1,a+L_ls[i],b,c)+10) min Min dfs(i+1,a+L_ls[i],b,c)+10 dfs(i+1,a+L_ls[i],b,c) dfs i+1 i 1 a+L_ls[i] a L_ls[i] L_ls i b c 10 if b == 0:
        Min = min(Min,dfs(i+1,a,b+L_ls[i],c))
    else:
        Min = min(Min,dfs(i+1,a,b+L_ls[i],c)+10)
    
     b == 0 b 0 Min = min(Min,dfs(i+1,a,b+L_ls[i],c)) Min min(Min,dfs(i+1,a,b+L_ls[i],c)) min Min dfs(i+1,a,b+L_ls[i],c) dfs i+1 i 1 a b+L_ls[i] b L_ls[i] L_ls i c Min = min(Min,dfs(i+1,a,b+L_ls[i],c)+10) Min min(Min,dfs(i+1,a,b+L_ls[i],c)+10) min Min dfs(i+1,a,b+L_ls[i],c)+10 dfs(i+1,a,b+L_ls[i],c) dfs i+1 i 1 a b+L_ls[i] b L_ls[i] L_ls i c 10 if c == 0:
        Min = min(Min,dfs(i+1,a,b,c+L_ls[i]))
    else:
        Min = min(Min,dfs(i+1,a,b,c+L_ls[i])+10)
    
     c == 0 c 0 Min = min(Min,dfs(i+1,a,b,c+L_ls[i])) Min min(Min,dfs(i+1,a,b,c+L_ls[i])) min Min dfs(i+1,a,b,c+L_ls[i]) dfs i+1 i 1 a b c+L_ls[i] c L_ls[i] L_ls i Min = min(Min,dfs(i+1,a,b,c+L_ls[i])+10) Min min(Min,dfs(i+1,a,b,c+L_ls[i])+10) min Min dfs(i+1,a,b,c+L_ls[i])+10 dfs(i+1,a,b,c+L_ls[i]) dfs i+1 i 1 a b c+L_ls[i] c L_ls[i] L_ls i 10 return Min Min 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)
    
    Min = dfs(i+1,a,b,c)

    if a == 0:
        Min = min(Min,dfs(i+1,a+L_ls[i],b,c))
    else:
        Min = min(Min,dfs(i+1,a+L_ls[i],b,c)+10)
    
    if b == 0:
        Min = min(Min,dfs(i+1,a,b+L_ls[i],c))
    else:
        Min = min(Min,dfs(i+1,a,b+L_ls[i],c)+10)
    
    if c == 0:
        Min = min(Min,dfs(i+1,a,b,c+L_ls[i]))
    else:
        Min = min(Min,dfs(i+1,a,b,c+L_ls[i])+10)
    
    return Min 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)
    
    Min = dfs(i+1,a,b,c)

    if a == 0:
        Min = min(Min,dfs(i+1,a+L_ls[i],b,c))
    else:
        Min = min(Min,dfs(i+1,a+L_ls[i],b,c)+10)
    
    if b == 0:
        Min = min(Min,dfs(i+1,a,b+L_ls[i],c))
    else:
        Min = min(Min,dfs(i+1,a,b+L_ls[i],c)+10)
    
    if c == 0:
        Min = min(Min,dfs(i+1,a,b,c+L_ls[i]))
    else:
        Min = min(Min,dfs(i+1,a,b,c+L_ls[i])+10)
    
    return Min dfs n,A,B,C = map(int,input().split()) map(int,input().split()) n L_ls = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] L_ls B,C = map(int,input().split()) map(int,input().split()) B C = map(int,input().split()) map(int,input().split()) C A,B,C = map(int,input().split()) map(int,input().split()) A
import sys
sys.setrecursionlimit(10**7)
n,A,B,C = map(int,input().split())
L_ls = [int(input()) for _ in range(n)]

# dfs(i,a,b,c) := i番目の竹のまえの時点で、A用の長さがa, B用の長さがb, C用の長さがcだった時の、それ以降の分岐での最初コスト
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)
    
    Min = dfs(i+1,a,b,c)

    if a == 0:
        Min = min(Min,dfs(i+1,a+L_ls[i],b,c))
    else:
        Min = min(Min,dfs(i+1,a+L_ls[i],b,c)+10)
    
    if b == 0:
        Min = min(Min,dfs(i+1,a,b+L_ls[i],c))
    else:
        Min = min(Min,dfs(i+1,a,b+L_ls[i],c)+10)
    
    if c == 0:
        Min = min(Min,dfs(i+1,a,b,c+L_ls[i]))
    else:
        Min = min(Min,dfs(i+1,a,b,c+L_ls[i])+10)
    
    return Min
print(dfs(0,0,0,0))