N,A,B,C = map(int,(input().split()))
l = [int(input()) for i in range(N)]

def dfs(cur,a,b,c):
    if cur == N:
        if min(a,b,c) > 0:
            return abs(a-A) + abs(b-B) + abs(c-C) -10*3 
        else:
            return 10**9
    c0 = dfs(cur+1,a,b,c)
    c1 = dfs(cur+1,a+l[cur],b,c) +10
    c2 = dfs(cur+1,a,b+l[cur],c) +10
    c3 = dfs(cur+1,a,b,c+l[cur]) +10
    return min(c0,c1,c2,c3)

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 i in range(N) for i in range(N) i range(N) range N for i in range(N) int(input()) int input() input l = [int(input()) for i in range(N)] l [int(input()) for i in range(N)] def dfs(cur,a,b,c):
    if cur == N:
        if min(a,b,c) > 0:
            return abs(a-A) + abs(b-B) + abs(c-C) -10*3 
        else:
            return 10**9
    c0 = dfs(cur+1,a,b,c)
    c1 = dfs(cur+1,a+l[cur],b,c) +10
    c2 = dfs(cur+1,a,b+l[cur],c) +10
    c3 = dfs(cur+1,a,b,c+l[cur]) +10
    return min(c0,c1,c2,c3) dfs if cur == N:
        if min(a,b,c) > 0:
            return abs(a-A) + abs(b-B) + abs(c-C) -10*3 
        else:
            return 10**9
     cur == N cur N if min(a,b,c) > 0:
            return abs(a-A) + abs(b-B) + abs(c-C) -10*3 
        else:
            return 10**9
     min(a,b,c) > 0 min(a,b,c) min a b c 0 return abs(a-A) + abs(b-B) + abs(c-C) -10*3 abs(a-A) + abs(b-B) + abs(c-C) -10*3 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*3 10 3 return 10**9 10**9 10 9 c0 = dfs(cur+1,a,b,c) c0 dfs(cur+1,a,b,c) dfs cur+1 cur 1 a b c c1 = dfs(cur+1,a+l[cur],b,c) +10 c1 dfs(cur+1,a+l[cur],b,c) +10 dfs(cur+1,a+l[cur],b,c) dfs cur+1 cur 1 a+l[cur] a l[cur] l cur b c 10 c2 = dfs(cur+1,a,b+l[cur],c) +10 c2 dfs(cur+1,a,b+l[cur],c) +10 dfs(cur+1,a,b+l[cur],c) dfs cur+1 cur 1 a b+l[cur] b l[cur] l cur c 10 c3 = dfs(cur+1,a,b,c+l[cur]) +10 c3 dfs(cur+1,a,b,c+l[cur]) +10 dfs(cur+1,a,b,c+l[cur]) dfs cur+1 cur 1 a b c+l[cur] c l[cur] l cur 10 return min(c0,c1,c2,c3) min(c0,c1,c2,c3) min c0 c1 c2 c3 cur cur a a b b c c print(dfs(0,0,0,0)) print dfs(0,0,0,0) dfs 0 0 0 0 N,A,B,C = map(int,(input().split())) map(int,(input().split())) N l = [int(input()) for i in range(N)] [int(input()) for i 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(cur,a,b,c):
    if cur == N:
        if min(a,b,c) > 0:
            return abs(a-A) + abs(b-B) + abs(c-C) -10*3 
        else:
            return 10**9
    c0 = dfs(cur+1,a,b,c)
    c1 = dfs(cur+1,a+l[cur],b,c) +10
    c2 = dfs(cur+1,a,b+l[cur],c) +10
    c3 = dfs(cur+1,a,b,c+l[cur]) +10
    return min(c0,c1,c2,c3) def dfs(cur,a,b,c):
    if cur == N:
        if min(a,b,c) > 0:
            return abs(a-A) + abs(b-B) + abs(c-C) -10*3 
        else:
            return 10**9
    c0 = dfs(cur+1,a,b,c)
    c1 = dfs(cur+1,a+l[cur],b,c) +10
    c2 = dfs(cur+1,a,b+l[cur],c) +10
    c3 = dfs(cur+1,a,b,c+l[cur]) +10
    return min(c0,c1,c2,c3) dfs B,C = map(int,(input().split())) map(int,(input().split())) B
N,A,B,C = map(int,(input().split()))
l = [int(input()) for i in range(N)]

def dfs(cur,a,b,c):
    if cur == N:
        if min(a,b,c) > 0:
            return abs(a-A) + abs(b-B) + abs(c-C) -10*3 
        else:
            return 10**9
    c0 = dfs(cur+1,a,b,c)
    c1 = dfs(cur+1,a+l[cur],b,c) +10
    c2 = dfs(cur+1,a,b+l[cur],c) +10
    c3 = dfs(cur+1,a,b,c+l[cur]) +10
    return min(c0,c1,c2,c3)

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