N,A,B,C = map(int,input().split())
l = [int(input()) for n in range(N)]
inf = 10 ** 18

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)-30
        else:
            return inf

    res0 = dfs(cur+1,a,b,c)
    res1 = dfs(cur+1,a+l[cur],b,c)+10
    res2 = dfs(cur+1,a,b+l[cur],c)+10
    res3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(res0,res1,res2,res3)
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 n in range(N) for n in range(N) n range(N) range N for n in range(N) int(input()) int input() input l = [int(input()) for n in range(N)] l [int(input()) for n in range(N)] inf = 10 ** 18 inf 10 ** 18 10 18 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)-30
        else:
            return inf

    res0 = dfs(cur+1,a,b,c)
    res1 = dfs(cur+1,a+l[cur],b,c)+10
    res2 = dfs(cur+1,a,b+l[cur],c)+10
    res3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(res0,res1,res2,res3) dfs if cur == N:
        if min(a,b,c) > 0:
            return abs(A-a)+abs(B-b)+abs(C-c)-30
        else:
            return inf

     cur == N cur 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 res0 = dfs(cur+1,a,b,c) res0 dfs(cur+1,a,b,c) dfs cur+1 cur 1 a b c res1 = dfs(cur+1,a+l[cur],b,c)+10 res1 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 res2 = dfs(cur+1,a,b+l[cur],c)+10 res2 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 res3 = dfs(cur+1,a,b,c+l[cur])+10 res3 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(res0,res1,res2,res3) min(res0,res1,res2,res3) min res0 res1 res2 res3 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 A,B,C = map(int,input().split()) map(int,input().split()) A B,C = map(int,input().split()) map(int,input().split()) B inf = 10 ** 18 10 ** 18 inf 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)-30
        else:
            return inf

    res0 = dfs(cur+1,a,b,c)
    res1 = dfs(cur+1,a+l[cur],b,c)+10
    res2 = dfs(cur+1,a,b+l[cur],c)+10
    res3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(res0,res1,res2,res3) 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)-30
        else:
            return inf

    res0 = dfs(cur+1,a,b,c)
    res1 = dfs(cur+1,a+l[cur],b,c)+10
    res2 = dfs(cur+1,a,b+l[cur],c)+10
    res3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(res0,res1,res2,res3) dfs N,A,B,C = map(int,input().split()) map(int,input().split()) N l = [int(input()) for n in range(N)] [int(input()) for n in range(N)] l
N,A,B,C = map(int,input().split())
l = [int(input()) for n in range(N)]
inf = 10 ** 18

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)-30
        else:
            return inf

    res0 = dfs(cur+1,a,b,c)
    res1 = dfs(cur+1,a+l[cur],b,c)+10
    res2 = dfs(cur+1,a,b+l[cur],c)+10
    res3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(res0,res1,res2,res3)
print(dfs(0,0,0,0))