N,A,B,C = map(int,input().split())

L = [int(input()) for _ in range(N)]
    
INF = 10**9

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

L = [int(input()) for _ in range(N)]
    
INF = 10**9

def dfs(i, a, b, c):
    if i == N:
        if min(a,b,c) > 0:
            return abs(a-A) + abs(b-B) + abs(c-C) - 30
        else:
            return INF
            
    ret1 = dfs(i+1, a, b, c)
    ret2 = dfs(i+1, a+L[i], b, c) + 10
    ret3 = dfs(i+1, a, b+L[i], c) + 10
    ret4 = dfs(i+1, a, b, c+L[i]) + 10
    return min(ret1,ret2,ret3,ret4)
    
print(dfs(0,0,0,0))