def check(s,e,t):
    global ans
    if(not s or not e or not t):
        return
    ans=min(ans,(len(s)-1)*10+abs(A-sum(s))+(len(e)-1)*10+abs(B-sum(e))+(len(t)-1)*10+abs(C-sum(t)))

def dfs(s,e,t,i):
    if(i==N):
        check(s,e,t)
        return
    dfs(s,e,t,i+1)
    dfs(s+[l[i]],e,t,i+1)
    dfs(s,e+[l[i]],t,i+1)
    dfs(s,e,t+[l[i]],i+1)

N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]

ans=10**18
dfs([],[],[],0)
print(ans) def check(s,e,t):
    global ans
    if(not s or not e or not t):
        return
    ans=min(ans,(len(s)-1)*10+abs(A-sum(s))+(len(e)-1)*10+abs(B-sum(e))+(len(t)-1)*10+abs(C-sum(t))) check global ans if(not s or not e or not t):
        return
     not s or not e or not t not s or not e not s s not e e not t t return ans=min(ans,(len(s)-1)*10+abs(A-sum(s))+(len(e)-1)*10+abs(B-sum(e))+(len(t)-1)*10+abs(C-sum(t))) ans min(ans,(len(s)-1)*10+abs(A-sum(s))+(len(e)-1)*10+abs(B-sum(e))+(len(t)-1)*10+abs(C-sum(t))) min ans (len(s)-1)*10+abs(A-sum(s))+(len(e)-1)*10+abs(B-sum(e))+(len(t)-1)*10+abs(C-sum(t)) (len(s)-1)*10+abs(A-sum(s))+(len(e)-1)*10+abs(B-sum(e))+(len(t)-1)*10 (len(s)-1)*10+abs(A-sum(s))+(len(e)-1)*10+abs(B-sum(e)) (len(s)-1)*10+abs(A-sum(s))+(len(e)-1)*10 (len(s)-1)*10+abs(A-sum(s)) (len(s)-1)*10 len(s)-1 len(s) len s 1 10 abs(A-sum(s)) abs A-sum(s) A sum(s) sum s (len(e)-1)*10 len(e)-1 len(e) len e 1 10 abs(B-sum(e)) abs B-sum(e) B sum(e) sum e (len(t)-1)*10 len(t)-1 len(t) len t 1 10 abs(C-sum(t)) abs C-sum(t) C sum(t) sum t s s e e t t def dfs(s,e,t,i):
    if(i==N):
        check(s,e,t)
        return
    dfs(s,e,t,i+1)
    dfs(s+[l[i]],e,t,i+1)
    dfs(s,e+[l[i]],t,i+1)
    dfs(s,e,t+[l[i]],i+1) dfs if(i==N):
        check(s,e,t)
        return
     i==N i N check(s,e,t) check s e t return dfs(s,e,t,i+1) dfs s e t i+1 i 1 dfs(s+[l[i]],e,t,i+1) dfs s+[l[i]] s [l[i]] l[i] l i e t i+1 i 1 dfs(s,e+[l[i]],t,i+1) dfs s e+[l[i]] e [l[i]] l[i] l i t i+1 i 1 dfs(s,e,t+[l[i]],i+1) dfs s e t+[l[i]] t [l[i]] l[i] l i i+1 i 1 s s e e t t i i 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)] ans=10**18 ans 10**18 10 18 dfs([],[],[],0) dfs [] [] [] 0 print(ans) print ans C=map(int,input().split()) map(int,input().split()) C def dfs(s,e,t,i):
    if(i==N):
        check(s,e,t)
        return
    dfs(s,e,t,i+1)
    dfs(s+[l[i]],e,t,i+1)
    dfs(s,e+[l[i]],t,i+1)
    dfs(s,e,t+[l[i]],i+1) def dfs(s,e,t,i):
    if(i==N):
        check(s,e,t)
        return
    dfs(s,e,t,i+1)
    dfs(s+[l[i]],e,t,i+1)
    dfs(s,e+[l[i]],t,i+1)
    dfs(s,e,t+[l[i]],i+1) dfs l=[int(input()) for i in range(N)] [int(input()) for i in range(N)] l ans=10**18 10**18 ans B,C=map(int,input().split()) map(int,input().split()) B N,A,B,C=map(int,input().split()) map(int,input().split()) N def check(s,e,t):
    global ans
    if(not s or not e or not t):
        return
    ans=min(ans,(len(s)-1)*10+abs(A-sum(s))+(len(e)-1)*10+abs(B-sum(e))+(len(t)-1)*10+abs(C-sum(t))) def check(s,e,t):
    global ans
    if(not s or not e or not t):
        return
    ans=min(ans,(len(s)-1)*10+abs(A-sum(s))+(len(e)-1)*10+abs(B-sum(e))+(len(t)-1)*10+abs(C-sum(t))) check A,B,C=map(int,input().split()) map(int,input().split()) A
def check(s,e,t):
    global ans
    if(not s or not e or not t):
        return
    ans=min(ans,(len(s)-1)*10+abs(A-sum(s))+(len(e)-1)*10+abs(B-sum(e))+(len(t)-1)*10+abs(C-sum(t)))

def dfs(s,e,t,i):
    if(i==N):
        check(s,e,t)
        return
    dfs(s,e,t,i+1)
    dfs(s+[l[i]],e,t,i+1)
    dfs(s,e+[l[i]],t,i+1)
    dfs(s,e,t+[l[i]],i+1)

N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]

ans=10**18
dfs([],[],[],0)
print(ans)