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

AMP=0
BMP=0
CMP=0
MP=10**5

def dfs(S,N,l,A,B,C):
    A_l=0
    B_l=0
    C_l=0
    A_cnt=0
    B_cnt=0
    C_cnt=0
    if len(S)==N:
        #calcurlate length and merge MP
        for n in range(N):
            if S[n]==0:
                pass
            elif S[n]==1:
                A_l+=l[n]
                A_cnt+=1
            elif S[n]==2:
                B_l+=l[n]
                B_cnt+=1
            else:
                C_l+=l[n]
                C_cnt+=1
        #calculate lengthen and shorten MP
        global MP
        if A_cnt>=1 and B_cnt>=1 and C_cnt>=1:
            MP=min(MP,(A_cnt-1+B_cnt-1+C_cnt-1)*10+abs(A-A_l)+abs(B-B_l)+abs(C-C_l))
        return
    else:
        for n in range(4):
            S.append(n)
            dfs(S,N,l,A,B,C)
            S.pop()

dfs([],N,l,A,B,C)
print(MP) N,A,B,C=map(int,input().strip().split()) N map(int,input().strip().split()) map int input().strip().split() ().strip().split ().strip() ().strip () input strip split A B C int(input()) for n in range(N) for n in range(N) n range(N) range N for n in range(N) int(input()) int input() input l=[int(input()) for n in range(N)] l [int(input()) for n in range(N)] AMP=0 AMP 0 BMP=0 BMP 0 CMP=0 CMP 0 MP=10**5 MP 10**5 10 5 def dfs(S,N,l,A,B,C):
    A_l=0
    B_l=0
    C_l=0
    A_cnt=0
    B_cnt=0
    C_cnt=0
    if len(S)==N:
        #calcurlate length and merge MP
        for n in range(N):
            if S[n]==0:
                pass
            elif S[n]==1:
                A_l+=l[n]
                A_cnt+=1
            elif S[n]==2:
                B_l+=l[n]
                B_cnt+=1
            else:
                C_l+=l[n]
                C_cnt+=1
        #calculate lengthen and shorten MP
        global MP
        if A_cnt>=1 and B_cnt>=1 and C_cnt>=1:
            MP=min(MP,(A_cnt-1+B_cnt-1+C_cnt-1)*10+abs(A-A_l)+abs(B-B_l)+abs(C-C_l))
        return
    else:
        for n in range(4):
            S.append(n)
            dfs(S,N,l,A,B,C)
            S.pop() dfs A_l=0 A_l 0 B_l=0 B_l 0 C_l=0 C_l 0 A_cnt=0 A_cnt 0 B_cnt=0 B_cnt 0 C_cnt=0 C_cnt 0 if len(S)==N:
        #calcurlate length and merge MP
        for n in range(N):
            if S[n]==0:
                pass
            elif S[n]==1:
                A_l+=l[n]
                A_cnt+=1
            elif S[n]==2:
                B_l+=l[n]
                B_cnt+=1
            else:
                C_l+=l[n]
                C_cnt+=1
        #calculate lengthen and shorten MP
        global MP
        if A_cnt>=1 and B_cnt>=1 and C_cnt>=1:
            MP=min(MP,(A_cnt-1+B_cnt-1+C_cnt-1)*10+abs(A-A_l)+abs(B-B_l)+abs(C-C_l))
        return
    else:
        for n in range(4):
            S.append(n)
            dfs(S,N,l,A,B,C)
            S.pop() len(S)==N len(S) len S N for n in range(N):
            if S[n]==0:
                pass
            elif S[n]==1:
                A_l+=l[n]
                A_cnt+=1
            elif S[n]==2:
                B_l+=l[n]
                B_cnt+=1
            else:
                C_l+=l[n]
                C_cnt+=1
        #calculate lengthen and shorten MP
         n range(N) range N if S[n]==0:
                pass
            elif S[n]==1:
                A_l+=l[n]
                A_cnt+=1
            elif S[n]==2:
                B_l+=l[n]
                B_cnt+=1
            else:
                C_l+=l[n]
                C_cnt+=1
        #calculate lengthen and shorten MP
         S[n]==0 S[n] S n 0 elif S[n]==1:
                A_l+=l[n]
                A_cnt+=1
             S[n]==1 S[n] S n 1 A_l+=l[n] A_l l[n] l n A_cnt+=1 A_cnt 1 elif S[n]==2:
                B_l+=l[n]
                B_cnt+=1
             S[n]==2 S[n] S n 2 B_l+=l[n] B_l l[n] l n B_cnt+=1 B_cnt 1 C_l+=l[n] C_l l[n] l n C_cnt+=1 C_cnt 1 global MP if A_cnt>=1 and B_cnt>=1 and C_cnt>=1:
            MP=min(MP,(A_cnt-1+B_cnt-1+C_cnt-1)*10+abs(A-A_l)+abs(B-B_l)+abs(C-C_l))
         A_cnt>=1 and B_cnt>=1 and C_cnt>=1 A_cnt>=1 and B_cnt>=1 A_cnt>=1 A_cnt 1 B_cnt>=1 B_cnt 1 C_cnt>=1 C_cnt 1 MP=min(MP,(A_cnt-1+B_cnt-1+C_cnt-1)*10+abs(A-A_l)+abs(B-B_l)+abs(C-C_l)) MP min(MP,(A_cnt-1+B_cnt-1+C_cnt-1)*10+abs(A-A_l)+abs(B-B_l)+abs(C-C_l)) min MP (A_cnt-1+B_cnt-1+C_cnt-1)*10+abs(A-A_l)+abs(B-B_l)+abs(C-C_l) (A_cnt-1+B_cnt-1+C_cnt-1)*10+abs(A-A_l)+abs(B-B_l) (A_cnt-1+B_cnt-1+C_cnt-1)*10+abs(A-A_l) (A_cnt-1+B_cnt-1+C_cnt-1)*10 A_cnt-1+B_cnt-1+C_cnt-1 A_cnt-1+B_cnt-1+C_cnt A_cnt-1+B_cnt-1 A_cnt-1+B_cnt A_cnt-1 A_cnt 1 B_cnt 1 C_cnt 1 10 abs(A-A_l) abs A-A_l A A_l abs(B-B_l) abs B-B_l B B_l abs(C-C_l) abs C-C_l C C_l return for n in range(4):
            S.append(n)
            dfs(S,N,l,A,B,C)
            S.pop() n range(4) range 4 S.append(n) S.append S append n dfs(S,N,l,A,B,C) dfs S N l A B C S.pop() S.pop S pop S S N N l l A A B B C C dfs([],N,l,A,B,C) dfs [] N l A B C print(MP) print MP N,A,B,C=map(int,input().strip().split()) map(int,input().strip().split()) N l=[int(input()) for n in range(N)] [int(input()) for n in range(N)] l BMP=0 0 BMP A,B,C=map(int,input().strip().split()) map(int,input().strip().split()) A AMP=0 0 AMP MP=10**5 10**5 MP C=map(int,input().strip().split()) map(int,input().strip().split()) C def dfs(S,N,l,A,B,C):
    A_l=0
    B_l=0
    C_l=0
    A_cnt=0
    B_cnt=0
    C_cnt=0
    if len(S)==N:
        #calcurlate length and merge MP
        for n in range(N):
            if S[n]==0:
                pass
            elif S[n]==1:
                A_l+=l[n]
                A_cnt+=1
            elif S[n]==2:
                B_l+=l[n]
                B_cnt+=1
            else:
                C_l+=l[n]
                C_cnt+=1
        #calculate lengthen and shorten MP
        global MP
        if A_cnt>=1 and B_cnt>=1 and C_cnt>=1:
            MP=min(MP,(A_cnt-1+B_cnt-1+C_cnt-1)*10+abs(A-A_l)+abs(B-B_l)+abs(C-C_l))
        return
    else:
        for n in range(4):
            S.append(n)
            dfs(S,N,l,A,B,C)
            S.pop() def dfs(S,N,l,A,B,C):
    A_l=0
    B_l=0
    C_l=0
    A_cnt=0
    B_cnt=0
    C_cnt=0
    if len(S)==N:
        #calcurlate length and merge MP
        for n in range(N):
            if S[n]==0:
                pass
            elif S[n]==1:
                A_l+=l[n]
                A_cnt+=1
            elif S[n]==2:
                B_l+=l[n]
                B_cnt+=1
            else:
                C_l+=l[n]
                C_cnt+=1
        #calculate lengthen and shorten MP
        global MP
        if A_cnt>=1 and B_cnt>=1 and C_cnt>=1:
            MP=min(MP,(A_cnt-1+B_cnt-1+C_cnt-1)*10+abs(A-A_l)+abs(B-B_l)+abs(C-C_l))
        return
    else:
        for n in range(4):
            S.append(n)
            dfs(S,N,l,A,B,C)
            S.pop() dfs B,C=map(int,input().strip().split()) map(int,input().strip().split()) B CMP=0 0 CMP
N,A,B,C=map(int,input().strip().split())
l=[int(input()) for n in range(N)]

AMP=0
BMP=0
CMP=0
MP=10**5

def dfs(S,N,l,A,B,C):
    A_l=0
    B_l=0
    C_l=0
    A_cnt=0
    B_cnt=0
    C_cnt=0
    if len(S)==N:
        #calcurlate length and merge MP
        for n in range(N):
            if S[n]==0:
                pass
            elif S[n]==1:
                A_l+=l[n]
                A_cnt+=1
            elif S[n]==2:
                B_l+=l[n]
                B_cnt+=1
            else:
                C_l+=l[n]
                C_cnt+=1
        #calculate lengthen and shorten MP
        global MP
        if A_cnt>=1 and B_cnt>=1 and C_cnt>=1:
            MP=min(MP,(A_cnt-1+B_cnt-1+C_cnt-1)*10+abs(A-A_l)+abs(B-B_l)+abs(C-C_l))
        return
    else:
        for n in range(4):
            S.append(n)
            dfs(S,N,l,A,B,C)
            S.pop()

dfs([],N,l,A,B,C)
print(MP)