N,A,B,C=map(int,input().split())
l=[int(input()) for _ in range(N)]
INF=10**9
def chk(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
    r0=chk(i+1,a,b,c)
    r1=chk(i+1,a+l[i],b,c)+10
    r2=chk(i+1,a,b+l[i],c)+10
    r3=chk(i+1,a,b,c+l[i])+10
    return min(r0,r1,r2,r3)
print(chk(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 chk(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
    r0=chk(i+1,a,b,c)
    r1=chk(i+1,a+l[i],b,c)+10
    r2=chk(i+1,a,b+l[i],c)+10
    r3=chk(i+1,a,b,c+l[i])+10
    return min(r0,r1,r2,r3) chk 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 r0=chk(i+1,a,b,c) r0 chk(i+1,a,b,c) chk i+1 i 1 a b c r1=chk(i+1,a+l[i],b,c)+10 r1 chk(i+1,a+l[i],b,c)+10 chk(i+1,a+l[i],b,c) chk i+1 i 1 a+l[i] a l[i] l i b c 10 r2=chk(i+1,a,b+l[i],c)+10 r2 chk(i+1,a,b+l[i],c)+10 chk(i+1,a,b+l[i],c) chk i+1 i 1 a b+l[i] b l[i] l i c 10 r3=chk(i+1,a,b,c+l[i])+10 r3 chk(i+1,a,b,c+l[i])+10 chk(i+1,a,b,c+l[i]) chk i+1 i 1 a b c+l[i] c l[i] l i 10 return min(r0,r1,r2,r3) min(r0,r1,r2,r3) min r0 r1 r2 r3 i i a a b b c c print(chk(0,0,0,0)) print chk(0,0,0,0) chk 0 0 0 0 N,A,B,C=map(int,input().split()) map(int,input().split()) N C=map(int,input().split()) map(int,input().split()) C A,B,C=map(int,input().split()) map(int,input().split()) A INF=10**9 10**9 INF l=[int(input()) for _ in range(N)] [int(input()) for _ in range(N)] l B,C=map(int,input().split()) map(int,input().split()) B def chk(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
    r0=chk(i+1,a,b,c)
    r1=chk(i+1,a+l[i],b,c)+10
    r2=chk(i+1,a,b+l[i],c)+10
    r3=chk(i+1,a,b,c+l[i])+10
    return min(r0,r1,r2,r3) def chk(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
    r0=chk(i+1,a,b,c)
    r1=chk(i+1,a+l[i],b,c)+10
    r2=chk(i+1,a,b+l[i],c)+10
    r3=chk(i+1,a,b,c+l[i])+10
    return min(r0,r1,r2,r3) chk
N,A,B,C=map(int,input().split())
l=[int(input()) for _ in range(N)]
INF=10**9
def chk(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
    r0=chk(i+1,a,b,c)
    r1=chk(i+1,a+l[i],b,c)+10
    r2=chk(i+1,a,b+l[i],c)+10
    r3=chk(i+1,a,b,c+l[i])+10
    return min(r0,r1,r2,r3)
print(chk(0,0,0,0))