N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
INF = 100000000
def rec(i,a,b,c):
    if(i==N):
        return(abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF)
    ret0 = rec(i+1,a,b,c)
    ret1 = rec(i+1,a+l[i],b,c)+10
    ret2 = rec(i+1,a,b+l[i],c)+10
    ret3 = rec(i+1,a,b,c+l[i])+10
    return min(ret0,ret1,ret2,ret3)
print(rec(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)] INF = 100000000 INF 100000000 def rec(i,a,b,c):
    if(i==N):
        return(abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF)
    ret0 = rec(i+1,a,b,c)
    ret1 = rec(i+1,a+l[i],b,c)+10
    ret2 = rec(i+1,a,b+l[i],c)+10
    ret3 = rec(i+1,a,b,c+l[i])+10
    return min(ret0,ret1,ret2,ret3) rec if(i==N):
        return(abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF)
     i==N i N return(abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF) abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else 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 INF ret0 = rec(i+1,a,b,c) ret0 rec(i+1,a,b,c) rec i+1 i 1 a b c ret1 = rec(i+1,a+l[i],b,c)+10 ret1 rec(i+1,a+l[i],b,c)+10 rec(i+1,a+l[i],b,c) rec i+1 i 1 a+l[i] a l[i] l i b c 10 ret2 = rec(i+1,a,b+l[i],c)+10 ret2 rec(i+1,a,b+l[i],c)+10 rec(i+1,a,b+l[i],c) rec i+1 i 1 a b+l[i] b l[i] l i c 10 ret3 = rec(i+1,a,b,c+l[i])+10 ret3 rec(i+1,a,b,c+l[i])+10 rec(i+1,a,b,c+l[i]) rec i+1 i 1 a b c+l[i] c l[i] l i 10 return min(ret0,ret1,ret2,ret3) min(ret0,ret1,ret2,ret3) min ret0 ret1 ret2 ret3 i i a a b b c c print(rec(0,0,0,0)) print rec(0,0,0,0) rec 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 i in range(N)] [int(input()) for i in range(N)] l A,B,C = map(int,input().split()) map(int,input().split()) A def rec(i,a,b,c):
    if(i==N):
        return(abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF)
    ret0 = rec(i+1,a,b,c)
    ret1 = rec(i+1,a+l[i],b,c)+10
    ret2 = rec(i+1,a,b+l[i],c)+10
    ret3 = rec(i+1,a,b,c+l[i])+10
    return min(ret0,ret1,ret2,ret3) def rec(i,a,b,c):
    if(i==N):
        return(abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF)
    ret0 = rec(i+1,a,b,c)
    ret1 = rec(i+1,a+l[i],b,c)+10
    ret2 = rec(i+1,a,b+l[i],c)+10
    ret3 = rec(i+1,a,b,c+l[i])+10
    return min(ret0,ret1,ret2,ret3) rec INF = 100000000 100000000 INF N,A,B,C = map(int,input().split()) map(int,input().split()) N
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
INF = 100000000
def rec(i,a,b,c):
    if(i==N):
        return(abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF)
    ret0 = rec(i+1,a,b,c)
    ret1 = rec(i+1,a+l[i],b,c)+10
    ret2 = rec(i+1,a,b+l[i],c)+10
    ret3 = rec(i+1,a,b,c+l[i])+10
    return min(ret0,ret1,ret2,ret3)
print(rec(0,0,0,0))
