from itertools import permutations,product
N,A,B,C = map(int,input().split())
L = [int(input()) for _ in range(N)]
G = {0:[],1:[],2:[]}
cmin = 10**5
for x in permutations(range(N),3):
    for y in product(range(4),repeat=N-3):
        G[0] = [x[0]]
        G[1] = [x[1]]
        G[2] = [x[2]]
        G[3] = []
        Ind = list(range(N))
        Ind.remove(x[0])
        Ind.remove(x[1])
        Ind.remove(x[2])
        for i in range(N-3):
            G[y[i]].append(Ind[i])
        cA = 0
        nA = len(G[0])
        cA = (nA-1)*10
        xA = 0
        for j in range(nA):
            xA += L[G[0][j]]
        cA += abs(A-xA)
        cB = 0
        nB = len(G[1])
        cB = (nB-1)*10
        xB = 0
        for j in range(nB):
            xB += L[G[1][j]]
        cB += abs(B-xB)
        cC = 0
        nC = len(G[2])
        cC = (nC-1)*10
        xC = 0
        for j in range(nC):
            xC += L[G[2][j]]
        cC += abs(C-xC)
        cmin = min(cmin,cA+cB+cC)
print(cmin) from itertools import permutations,product 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)] G = {0:[],1:[],2:[]} G {0:[],1:[],2:[]} 0 0 [] 1 1 [] 2 2 [] cmin = 10**5 cmin 10**5 10 5 for x in permutations(range(N),3):
    for y in product(range(4),repeat=N-3):
        G[0] = [x[0]]
        G[1] = [x[1]]
        G[2] = [x[2]]
        G[3] = []
        Ind = list(range(N))
        Ind.remove(x[0])
        Ind.remove(x[1])
        Ind.remove(x[2])
        for i in range(N-3):
            G[y[i]].append(Ind[i])
        cA = 0
        nA = len(G[0])
        cA = (nA-1)*10
        xA = 0
        for j in range(nA):
            xA += L[G[0][j]]
        cA += abs(A-xA)
        cB = 0
        nB = len(G[1])
        cB = (nB-1)*10
        xB = 0
        for j in range(nB):
            xB += L[G[1][j]]
        cB += abs(B-xB)
        cC = 0
        nC = len(G[2])
        cC = (nC-1)*10
        xC = 0
        for j in range(nC):
            xC += L[G[2][j]]
        cC += abs(C-xC)
        cmin = min(cmin,cA+cB+cC) x permutations(range(N),3) permutations range(N) range N 3 for y in product(range(4),repeat=N-3):
        G[0] = [x[0]]
        G[1] = [x[1]]
        G[2] = [x[2]]
        G[3] = []
        Ind = list(range(N))
        Ind.remove(x[0])
        Ind.remove(x[1])
        Ind.remove(x[2])
        for i in range(N-3):
            G[y[i]].append(Ind[i])
        cA = 0
        nA = len(G[0])
        cA = (nA-1)*10
        xA = 0
        for j in range(nA):
            xA += L[G[0][j]]
        cA += abs(A-xA)
        cB = 0
        nB = len(G[1])
        cB = (nB-1)*10
        xB = 0
        for j in range(nB):
            xB += L[G[1][j]]
        cB += abs(B-xB)
        cC = 0
        nC = len(G[2])
        cC = (nC-1)*10
        xC = 0
        for j in range(nC):
            xC += L[G[2][j]]
        cC += abs(C-xC)
        cmin = min(cmin,cA+cB+cC) y product(range(4),repeat=N-3) product range(4) range 4 repeat=N-3 repeat N-3 N 3 G[0] = [x[0]] G[0] G 0 [x[0]] x[0] x 0 G[1] = [x[1]] G[1] G 1 [x[1]] x[1] x 1 G[2] = [x[2]] G[2] G 2 [x[2]] x[2] x 2 G[3] = [] G[3] G 3 [] Ind = list(range(N)) Ind list(range(N)) list range(N) range N Ind.remove(x[0]) Ind.remove Ind remove x[0] x 0 Ind.remove(x[1]) Ind.remove Ind remove x[1] x 1 Ind.remove(x[2]) Ind.remove Ind remove x[2] x 2 for i in range(N-3):
            G[y[i]].append(Ind[i])
         i range(N-3) range N-3 N 3 G[y[i]].append(Ind[i]) [y[i]].append [y[i]] G y[i] y i append Ind[i] Ind i cA = 0 cA 0 nA = len(G[0]) nA len(G[0]) len G[0] G 0 cA = (nA-1)*10 cA (nA-1)*10 nA-1 nA 1 10 xA = 0 xA 0 for j in range(nA):
            xA += L[G[0][j]]
         j range(nA) range nA xA += L[G[0][j]] xA L[G[0][j]] L G[0][j] [0] G 0 j cA += abs(A-xA) cA abs(A-xA) abs A-xA A xA cB = 0 cB 0 nB = len(G[1]) nB len(G[1]) len G[1] G 1 cB = (nB-1)*10 cB (nB-1)*10 nB-1 nB 1 10 xB = 0 xB 0 for j in range(nB):
            xB += L[G[1][j]]
         j range(nB) range nB xB += L[G[1][j]] xB L[G[1][j]] L G[1][j] [1] G 1 j cB += abs(B-xB) cB abs(B-xB) abs B-xB B xB cC = 0 cC 0 nC = len(G[2]) nC len(G[2]) len G[2] G 2 cC = (nC-1)*10 cC (nC-1)*10 nC-1 nC 1 10 xC = 0 xC 0 for j in range(nC):
            xC += L[G[2][j]]
         j range(nC) range nC xC += L[G[2][j]] xC L[G[2][j]] L G[2][j] [2] G 2 j cC += abs(C-xC) cC abs(C-xC) abs C-xC C xC cmin = min(cmin,cA+cB+cC) cmin min(cmin,cA+cB+cC) min cmin cA+cB+cC cA+cB cA cB cC print(cmin) print cmin xC += L[G[2][j]] L[G[2][j]] xC A,B,C = map(int,input().split()) map(int,input().split()) A cC = (nC-1)*10 (nC-1)*10 cC N,A,B,C = map(int,input().split()) map(int,input().split()) N nA = len(G[0]) len(G[0]) nA cC = 0 0 cC cB += abs(B-xB) abs(B-xB) cB xA = 0 0 xA xB = 0 0 xB cC += abs(C-xC) abs(C-xC) cC nB = len(G[1]) len(G[1]) nB cA = (nA-1)*10 (nA-1)*10 cA xA += L[G[0][j]] L[G[0][j]] xA B,C = map(int,input().split()) map(int,input().split()) B cB = (nB-1)*10 (nB-1)*10 cB cA += abs(A-xA) abs(A-xA) cA cmin = 10**5 10**5 cmin G = {0:[],1:[],2:[]} {0:[],1:[],2:[]} G nC = len(G[2]) len(G[2]) nC L = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] L C = map(int,input().split()) map(int,input().split()) C cB = 0 0 cB xC = 0 0 xC cmin = min(cmin,cA+cB+cC) min(cmin,cA+cB+cC) cmin Ind = list(range(N)) list(range(N)) Ind xB += L[G[1][j]] L[G[1][j]] xB cA = 0 0 cA
from itertools import permutations,product
N,A,B,C = map(int,input().split())
L = [int(input()) for _ in range(N)]
G = {0:[],1:[],2:[]}
cmin = 10**5
for x in permutations(range(N),3):
    for y in product(range(4),repeat=N-3):
        G[0] = [x[0]]
        G[1] = [x[1]]
        G[2] = [x[2]]
        G[3] = []
        Ind = list(range(N))
        Ind.remove(x[0])
        Ind.remove(x[1])
        Ind.remove(x[2])
        for i in range(N-3):
            G[y[i]].append(Ind[i])
        cA = 0
        nA = len(G[0])
        cA = (nA-1)*10
        xA = 0
        for j in range(nA):
            xA += L[G[0][j]]
        cA += abs(A-xA)
        cB = 0
        nB = len(G[1])
        cB = (nB-1)*10
        xB = 0
        for j in range(nB):
            xB += L[G[1][j]]
        cB += abs(B-xB)
        cC = 0
        nC = len(G[2])
        cC = (nC-1)*10
        xC = 0
        for j in range(nC):
            xC += L[G[2][j]]
        cC += abs(C-xC)
        cmin = min(cmin,cA+cB+cC)
print(cmin)