def dfs(now1, now2, now3, d):
    if d==N:
        if min(now1, now2, now3)==0:
            return 10**18
            
        return abs(A-now1)+abs(B-now2)+abs(C-now3)
        
    res = 10**18
    res = min(res, dfs(now1+l[d], now2, now3, d+1)+10)
    res = min(res, dfs(now1, now2+l[d], now3, d+1)+10)
    res = min(res, dfs(now1, now2, now3+l[d], d+1)+10)
    res = min(res, dfs(now1, now2, now3, d+1))
    
    return res

N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
print(dfs(0, 0, 0, 0)-30) def dfs(now1, now2, now3, d):
    if d==N:
        if min(now1, now2, now3)==0:
            return 10**18
            
        return abs(A-now1)+abs(B-now2)+abs(C-now3)
        
    res = 10**18
    res = min(res, dfs(now1+l[d], now2, now3, d+1)+10)
    res = min(res, dfs(now1, now2+l[d], now3, d+1)+10)
    res = min(res, dfs(now1, now2, now3+l[d], d+1)+10)
    res = min(res, dfs(now1, now2, now3, d+1))
    
    return res dfs if d==N:
        if min(now1, now2, now3)==0:
            return 10**18
            
        return abs(A-now1)+abs(B-now2)+abs(C-now3)
        
     d==N d N if min(now1, now2, now3)==0:
            return 10**18
            
         min(now1, now2, now3)==0 min(now1, now2, now3) min now1 now2 now3 0 return 10**18 10**18 10 18 return abs(A-now1)+abs(B-now2)+abs(C-now3) abs(A-now1)+abs(B-now2)+abs(C-now3) abs(A-now1)+abs(B-now2) abs(A-now1) abs A-now1 A now1 abs(B-now2) abs B-now2 B now2 abs(C-now3) abs C-now3 C now3 res = 10**18 res 10**18 10 18 res = min(res, dfs(now1+l[d], now2, now3, d+1)+10) res min(res, dfs(now1+l[d], now2, now3, d+1)+10) min res dfs(now1+l[d], now2, now3, d+1)+10 dfs(now1+l[d], now2, now3, d+1) dfs now1+l[d] now1 l[d] l d now2 now3 d+1 d 1 10 res = min(res, dfs(now1, now2+l[d], now3, d+1)+10) res min(res, dfs(now1, now2+l[d], now3, d+1)+10) min res dfs(now1, now2+l[d], now3, d+1)+10 dfs(now1, now2+l[d], now3, d+1) dfs now1 now2+l[d] now2 l[d] l d now3 d+1 d 1 10 res = min(res, dfs(now1, now2, now3+l[d], d+1)+10) res min(res, dfs(now1, now2, now3+l[d], d+1)+10) min res dfs(now1, now2, now3+l[d], d+1)+10 dfs(now1, now2, now3+l[d], d+1) dfs now1 now2 now3+l[d] now3 l[d] l d d+1 d 1 10 res = min(res, dfs(now1, now2, now3, d+1)) res min(res, dfs(now1, now2, now3, d+1)) min res dfs(now1, now2, now3, d+1) dfs now1 now2 now3 d+1 d 1 return res res now1 now1 now2 now2 now3 now3 d d 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)] print(dfs(0, 0, 0, 0)-30) print dfs(0, 0, 0, 0)-30 dfs(0, 0, 0, 0) dfs 0 0 0 0 30 N, A, B, C = map(int, input().split()) map(int, input().split()) N B, C = map(int, input().split()) map(int, input().split()) B l = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] l A, B, C = map(int, input().split()) map(int, input().split()) A C = map(int, input().split()) map(int, input().split()) C def dfs(now1, now2, now3, d):
    if d==N:
        if min(now1, now2, now3)==0:
            return 10**18
            
        return abs(A-now1)+abs(B-now2)+abs(C-now3)
        
    res = 10**18
    res = min(res, dfs(now1+l[d], now2, now3, d+1)+10)
    res = min(res, dfs(now1, now2+l[d], now3, d+1)+10)
    res = min(res, dfs(now1, now2, now3+l[d], d+1)+10)
    res = min(res, dfs(now1, now2, now3, d+1))
    
    return res def dfs(now1, now2, now3, d):
    if d==N:
        if min(now1, now2, now3)==0:
            return 10**18
            
        return abs(A-now1)+abs(B-now2)+abs(C-now3)
        
    res = 10**18
    res = min(res, dfs(now1+l[d], now2, now3, d+1)+10)
    res = min(res, dfs(now1, now2+l[d], now3, d+1)+10)
    res = min(res, dfs(now1, now2, now3+l[d], d+1)+10)
    res = min(res, dfs(now1, now2, now3, d+1))
    
    return res dfs
def dfs(now1, now2, now3, d):
    if d==N:
        if min(now1, now2, now3)==0:
            return 10**18
            
        return abs(A-now1)+abs(B-now2)+abs(C-now3)
        
    res = 10**18
    res = min(res, dfs(now1+l[d], now2, now3, d+1)+10)
    res = min(res, dfs(now1, now2+l[d], now3, d+1)+10)
    res = min(res, dfs(now1, now2, now3+l[d], d+1)+10)
    res = min(res, dfs(now1, now2, now3, d+1))
    
    return res

N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
print(dfs(0, 0, 0, 0)-30)