def dfs(cnt,a,b,c):
    if cnt == N:
        _sum = abs(A-a) + abs(B-b) + abs(C-c) - 30
        return _sum if min(a,b,c) > 0 else 10**9
    ret0 = dfs(cnt+1, a, b, c)
    ret1 = dfs(cnt+1, a+l[cnt] , b, c) + 10
    ret2 = dfs(cnt+1, a, b+l[cnt], c) + 10
    ret3 = dfs(cnt+1, a, b, c+l[cnt]) + 10
    return min(ret0,ret1,ret2,ret3) 
    
N,A,B,C,*l = map(int,open(0).read().split())
print(dfs(0,0,0,0)) def dfs(cnt,a,b,c):
    if cnt == N:
        _sum = abs(A-a) + abs(B-b) + abs(C-c) - 30
        return _sum if min(a,b,c) > 0 else 10**9
    ret0 = dfs(cnt+1, a, b, c)
    ret1 = dfs(cnt+1, a+l[cnt] , b, c) + 10
    ret2 = dfs(cnt+1, a, b+l[cnt], c) + 10
    ret3 = dfs(cnt+1, a, b, c+l[cnt]) + 10
    return min(ret0,ret1,ret2,ret3) 
     dfs if cnt == N:
        _sum = abs(A-a) + abs(B-b) + abs(C-c) - 30
        return _sum if min(a,b,c) > 0 else 10**9
     cnt == N cnt N _sum = abs(A-a) + abs(B-b) + abs(C-c) - 30 _sum 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 _sum if min(a,b,c) > 0 else 10**9 _sum if min(a,b,c) > 0 else 10**9 min(a,b,c) > 0 min(a,b,c) min a b c 0 _sum 10**9 10 9 ret0 = dfs(cnt+1, a, b, c) ret0 dfs(cnt+1, a, b, c) dfs cnt+1 cnt 1 a b c ret1 = dfs(cnt+1, a+l[cnt] , b, c) + 10 ret1 dfs(cnt+1, a+l[cnt] , b, c) + 10 dfs(cnt+1, a+l[cnt] , b, c) dfs cnt+1 cnt 1 a+l[cnt] a l[cnt] l cnt b c 10 ret2 = dfs(cnt+1, a, b+l[cnt], c) + 10 ret2 dfs(cnt+1, a, b+l[cnt], c) + 10 dfs(cnt+1, a, b+l[cnt], c) dfs cnt+1 cnt 1 a b+l[cnt] b l[cnt] l cnt c 10 ret3 = dfs(cnt+1, a, b, c+l[cnt]) + 10 ret3 dfs(cnt+1, a, b, c+l[cnt]) + 10 dfs(cnt+1, a, b, c+l[cnt]) dfs cnt+1 cnt 1 a b c+l[cnt] c l[cnt] l cnt 10 return min(ret0,ret1,ret2,ret3) min(ret0,ret1,ret2,ret3) min ret0 ret1 ret2 ret3 cnt cnt a a b b c c N,A,B,C,*l = map(int,open(0).read().split()) N map(int,open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split A B C *l l print(dfs(0,0,0,0)) print dfs(0,0,0,0) dfs 0 0 0 0 A,B,C,*l = map(int,open(0).read().split()) map(int,open(0).read().split()) A B,C,*l = map(int,open(0).read().split()) map(int,open(0).read().split()) B def dfs(cnt,a,b,c):
    if cnt == N:
        _sum = abs(A-a) + abs(B-b) + abs(C-c) - 30
        return _sum if min(a,b,c) > 0 else 10**9
    ret0 = dfs(cnt+1, a, b, c)
    ret1 = dfs(cnt+1, a+l[cnt] , b, c) + 10
    ret2 = dfs(cnt+1, a, b+l[cnt], c) + 10
    ret3 = dfs(cnt+1, a, b, c+l[cnt]) + 10
    return min(ret0,ret1,ret2,ret3) 
     def dfs(cnt,a,b,c):
    if cnt == N:
        _sum = abs(A-a) + abs(B-b) + abs(C-c) - 30
        return _sum if min(a,b,c) > 0 else 10**9
    ret0 = dfs(cnt+1, a, b, c)
    ret1 = dfs(cnt+1, a+l[cnt] , b, c) + 10
    ret2 = dfs(cnt+1, a, b+l[cnt], c) + 10
    ret3 = dfs(cnt+1, a, b, c+l[cnt]) + 10
    return min(ret0,ret1,ret2,ret3) 
     dfs C,*l = map(int,open(0).read().split()) map(int,open(0).read().split()) C N,A,B,C,*l = map(int,open(0).read().split()) map(int,open(0).read().split()) N
def dfs(cnt,a,b,c):
    if cnt == N:
        _sum = abs(A-a) + abs(B-b) + abs(C-c) - 30
        return _sum if min(a,b,c) > 0 else 10**9
    ret0 = dfs(cnt+1, a, b, c)
    ret1 = dfs(cnt+1, a+l[cnt] , b, c) + 10
    ret2 = dfs(cnt+1, a, b+l[cnt], c) + 10
    ret3 = dfs(cnt+1, a, b, c+l[cnt]) + 10
    return min(ret0,ret1,ret2,ret3) 
    
N,A,B,C,*l = map(int,open(0).read().split())
print(dfs(0,0,0,0))