n,a,b,c = map(int,input().split())
t = [int(input()) for i in range(n)]
ans = float('inf')
for i in range(1<<(n*2)):
    tmp,cnt,a_t,b_t,c_t = i,0,0,0,0
    for j in range(n):
        if tmp&3==1:
            a_t+=t[j]
            if a_t!=t[j]: cnt+=10
        elif tmp&3==2:
            b_t+=t[j]
            if b_t!=t[j]: cnt+=10
        elif tmp&3==3:
            c_t+=t[j]
            if c_t!=t[j]: cnt+=10
        tmp >>= 2
    if a_t==0 or b_t==0 or c_t==0: continue
    tmp = abs(a-a_t)+abs(b-b_t)+abs(c-c_t)+cnt
    ans = min(ans,tmp)
print(ans) 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 t = [int(input()) for i in range(n)] t [int(input()) for i in range(n)] ans = float('inf') ans float('inf') float 'inf' for i in range(1<<(n*2)):
    tmp,cnt,a_t,b_t,c_t = i,0,0,0,0
    for j in range(n):
        if tmp&3==1:
            a_t+=t[j]
            if a_t!=t[j]: cnt+=10
        elif tmp&3==2:
            b_t+=t[j]
            if b_t!=t[j]: cnt+=10
        elif tmp&3==3:
            c_t+=t[j]
            if c_t!=t[j]: cnt+=10
        tmp >>= 2
    if a_t==0 or b_t==0 or c_t==0: continue
    tmp = abs(a-a_t)+abs(b-b_t)+abs(c-c_t)+cnt
    ans = min(ans,tmp) i range(1<<(n*2)) range 1<<(n*2) 1 n*2 n 2 tmp,cnt,a_t,b_t,c_t = i,0,0,0,0 tmp i cnt 0 a_t 0 b_t 0 c_t 0 for j in range(n):
        if tmp&3==1:
            a_t+=t[j]
            if a_t!=t[j]: cnt+=10
        elif tmp&3==2:
            b_t+=t[j]
            if b_t!=t[j]: cnt+=10
        elif tmp&3==3:
            c_t+=t[j]
            if c_t!=t[j]: cnt+=10
        tmp >>= 2
     j range(n) range n if tmp&3==1:
            a_t+=t[j]
            if a_t!=t[j]: cnt+=10
        elif tmp&3==2:
            b_t+=t[j]
            if b_t!=t[j]: cnt+=10
        elif tmp&3==3:
            c_t+=t[j]
            if c_t!=t[j]: cnt+=10
         tmp&3==1 tmp&3 tmp 3 1 a_t+=t[j] a_t t[j] t j if a_t!=t[j]: cnt+=10
         a_t!=t[j] a_t t[j] t j elif tmp&3==2:
            b_t+=t[j]
            if b_t!=t[j]: cnt+=10
         tmp&3==2 tmp&3 tmp 3 2 b_t+=t[j] b_t t[j] t j if b_t!=t[j]: cnt+=10
         b_t!=t[j] b_t t[j] t j elif tmp&3==3:
            c_t+=t[j]
            if c_t!=t[j]: cnt+=10
         tmp&3==3 tmp&3 tmp 3 3 c_t+=t[j] c_t t[j] t j if c_t!=t[j]: cnt+=10
         c_t!=t[j] c_t t[j] t j tmp >>= 2 tmp 2 if a_t==0 or b_t==0 or c_t==0: continue
     a_t==0 or b_t==0 or c_t==0 a_t==0 or b_t==0 a_t==0 a_t 0 b_t==0 b_t 0 c_t==0 c_t 0 tmp = abs(a-a_t)+abs(b-b_t)+abs(c-c_t)+cnt tmp abs(a-a_t)+abs(b-b_t)+abs(c-c_t)+cnt abs(a-a_t)+abs(b-b_t)+abs(c-c_t) abs(a-a_t)+abs(b-b_t) abs(a-a_t) abs a-a_t a a_t abs(b-b_t) abs b-b_t b b_t abs(c-c_t) abs c-c_t c c_t cnt ans = min(ans,tmp) ans min(ans,tmp) min ans tmp print(ans) print ans b,c = map(int,input().split()) map(int,input().split()) b ans = float('inf') float('inf') ans a_t+=t[j] t[j] a_t ans = min(ans,tmp) min(ans,tmp) ans n,a,b,c = map(int,input().split()) map(int,input().split()) n c = map(int,input().split()) map(int,input().split()) c c_t = i,0,0,0,0 0 c_t a_t,b_t,c_t = i,0,0,0,0 0 a_t cnt,a_t,b_t,c_t = i,0,0,0,0 0 cnt tmp = abs(a-a_t)+abs(b-b_t)+abs(c-c_t)+cnt abs(a-a_t)+abs(b-b_t)+abs(c-c_t)+cnt tmp b_t+=t[j] t[j] b_t a,b,c = map(int,input().split()) map(int,input().split()) a b_t,c_t = i,0,0,0,0 0 b_t tmp,cnt,a_t,b_t,c_t = i,0,0,0,0 i tmp tmp >>= 2 2 tmp t = [int(input()) for i in range(n)] [int(input()) for i in range(n)] t c_t+=t[j] t[j] c_t
n,a,b,c = map(int,input().split())
t = [int(input()) for i in range(n)]
ans = float('inf')
for i in range(1<<(n*2)):
    tmp,cnt,a_t,b_t,c_t = i,0,0,0,0
    for j in range(n):
        if tmp&3==1:
            a_t+=t[j]
            if a_t!=t[j]: cnt+=10
        elif tmp&3==2:
            b_t+=t[j]
            if b_t!=t[j]: cnt+=10
        elif tmp&3==3:
            c_t+=t[j]
            if c_t!=t[j]: cnt+=10
        tmp >>= 2
    if a_t==0 or b_t==0 or c_t==0: continue
    tmp = abs(a-a_t)+abs(b-b_t)+abs(c-c_t)+cnt
    ans = min(ans,tmp)
print(ans)
