n,A,B,C=map(int,input().split())
l=[]
for _ in range(n):
    l.append(int(input()))
def solve(cur,a,b,c):
    if cur==n:
        #base case
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else float('INF')
    ret0=solve(cur+1,a,b,c)
    ret1=solve(cur+1,a+l[cur],b,c)+10
    ret2=solve(cur+1,a,b+l[cur],c)+10
    ret3=solve(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)
print(solve(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 l=[] l [] for _ in range(n):
    l.append(int(input())) _ range(n) range n l.append(int(input())) l.append l append int(input()) int input() input def solve(cur,a,b,c):
    if cur==n:
        #base case
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else float('INF')
    ret0=solve(cur+1,a,b,c)
    ret1=solve(cur+1,a+l[cur],b,c)+10
    ret2=solve(cur+1,a,b+l[cur],c)+10
    ret3=solve(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3) solve if cur==n:
        #base case
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else float('INF')
     cur==n cur n return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else float('INF') abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else float('INF') min(a,b,c)>0 min(a,b,c) min a b c 0 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 float('INF') float 'INF' ret0=solve(cur+1,a,b,c) ret0 solve(cur+1,a,b,c) solve cur+1 cur 1 a b c ret1=solve(cur+1,a+l[cur],b,c)+10 ret1 solve(cur+1,a+l[cur],b,c)+10 solve(cur+1,a+l[cur],b,c) solve cur+1 cur 1 a+l[cur] a l[cur] l cur b c 10 ret2=solve(cur+1,a,b+l[cur],c)+10 ret2 solve(cur+1,a,b+l[cur],c)+10 solve(cur+1,a,b+l[cur],c) solve cur+1 cur 1 a b+l[cur] b l[cur] l cur c 10 ret3=solve(cur+1,a,b,c+l[cur])+10 ret3 solve(cur+1,a,b,c+l[cur])+10 solve(cur+1,a,b,c+l[cur]) solve cur+1 cur 1 a b c+l[cur] c l[cur] l cur 10 return min(ret0,ret1,ret2,ret3) min(ret0,ret1,ret2,ret3) min ret0 ret1 ret2 ret3 cur cur a a b b c c print(solve(0,0,0,0)) print solve(0,0,0,0) solve 0 0 0 0 C=map(int,input().split()) map(int,input().split()) C n,A,B,C=map(int,input().split()) map(int,input().split()) n A,B,C=map(int,input().split()) map(int,input().split()) A def solve(cur,a,b,c):
    if cur==n:
        #base case
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else float('INF')
    ret0=solve(cur+1,a,b,c)
    ret1=solve(cur+1,a+l[cur],b,c)+10
    ret2=solve(cur+1,a,b+l[cur],c)+10
    ret3=solve(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3) def solve(cur,a,b,c):
    if cur==n:
        #base case
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else float('INF')
    ret0=solve(cur+1,a,b,c)
    ret1=solve(cur+1,a+l[cur],b,c)+10
    ret2=solve(cur+1,a,b+l[cur],c)+10
    ret3=solve(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3) solve l=[] [] l B,C=map(int,input().split()) map(int,input().split()) B
n,A,B,C=map(int,input().split())
l=[]
for _ in range(n):
    l.append(int(input()))
def solve(cur,a,b,c):
    if cur==n:
        #base case
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else float('INF')
    ret0=solve(cur+1,a,b,c)
    ret1=solve(cur+1,a+l[cur],b,c)+10
    ret2=solve(cur+1,a,b+l[cur],c)+10
    ret3=solve(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)
print(solve(0,0,0,0))
