N, A, B, C = map(int, input().split())
L = [0]*N
for i in range(N):
  L[i] = int(input())

import itertools
bambuu = [[0,0,0] for _ in range(4**N)]
for i,pro in enumerate(itertools.product(['A','B',"C",'D'], repeat=N)):
    lisA = [L[j] for j in range(N) if pro[j]=='A']
    lisB = [L[j] for j in range(N) if pro[j]=='B']
    lisC = [L[j] for j in range(N) if pro[j]=='C']
    sumA = [sum(lisA),(len(lisA)-1)*10]
    sumB = [sum(lisB),(len(lisB)-1)*10]
    sumC = [sum(lisC),(len(lisC)-1)*10]
    bambuu[i-1] = [sumA,sumB,sumC]

ans = 10000
for sA,sB,sC in bambuu:
    if sA[0]>0 and sB[0]>0 and sC[0]>0:
        mp_total = abs(A-sA[0])+abs(B-sB[0])+abs(C-sC[0])+sA[1]+sB[1]+sC[1]
        if mp_total < ans:
            #record = [sA,sB,sC]
            ans = mp_total
#print(record)
print(ans)
#print(*ans, sep='\n') N, A, B, C = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split A B C L = [0]*N L [0]*N [0] 0 N for i in range(N):
  L[i] = int(input()) i range(N) range N L[i] = int(input()) L[i] L i int(input()) int input() input import itertools itertools [0,0,0] for _ in range(4**N) for _ in range(4**N) _ range(4**N) range 4**N 4 N for _ in range(4**N) [0,0,0] 0 0 0 bambuu = [[0,0,0] for _ in range(4**N)] bambuu [[0,0,0] for _ in range(4**N)] for i,pro in enumerate(itertools.product(['A','B',"C",'D'], repeat=N)):
    lisA = [L[j] for j in range(N) if pro[j]=='A']
    lisB = [L[j] for j in range(N) if pro[j]=='B']
    lisC = [L[j] for j in range(N) if pro[j]=='C']
    sumA = [sum(lisA),(len(lisA)-1)*10]
    sumB = [sum(lisB),(len(lisB)-1)*10]
    sumC = [sum(lisC),(len(lisC)-1)*10]
    bambuu[i-1] = [sumA,sumB,sumC] i pro enumerate(itertools.product(['A','B',"C",'D'], repeat=N)) enumerate itertools.product(['A','B',"C",'D'], repeat=N) itertools.product itertools product ['A','B',"C",'D'] 'A' 'B' "C" 'D' repeat=N repeat N L[j] for j in range(N) if pro[j]=='A' for j in range(N) if pro[j]=='A' j range(N) range N pro[j]=='A' pro[j] pro j 'A' if pro[j]=='A' L[j] L j lisA = [L[j] for j in range(N) if pro[j]=='A'] lisA [L[j] for j in range(N) if pro[j]=='A'] L[j] for j in range(N) if pro[j]=='B' for j in range(N) if pro[j]=='B' j range(N) range N pro[j]=='B' pro[j] pro j 'B' if pro[j]=='B' L[j] L j lisB = [L[j] for j in range(N) if pro[j]=='B'] lisB [L[j] for j in range(N) if pro[j]=='B'] L[j] for j in range(N) if pro[j]=='C' for j in range(N) if pro[j]=='C' j range(N) range N pro[j]=='C' pro[j] pro j 'C' if pro[j]=='C' L[j] L j lisC = [L[j] for j in range(N) if pro[j]=='C'] lisC [L[j] for j in range(N) if pro[j]=='C'] sumA = [sum(lisA),(len(lisA)-1)*10] sumA [sum(lisA),(len(lisA)-1)*10] sum(lisA) sum lisA (len(lisA)-1)*10 len(lisA)-1 len(lisA) len lisA 1 10 sumB = [sum(lisB),(len(lisB)-1)*10] sumB [sum(lisB),(len(lisB)-1)*10] sum(lisB) sum lisB (len(lisB)-1)*10 len(lisB)-1 len(lisB) len lisB 1 10 sumC = [sum(lisC),(len(lisC)-1)*10] sumC [sum(lisC),(len(lisC)-1)*10] sum(lisC) sum lisC (len(lisC)-1)*10 len(lisC)-1 len(lisC) len lisC 1 10 bambuu[i-1] = [sumA,sumB,sumC] bambuu[i-1] bambuu i-1 i 1 [sumA,sumB,sumC] sumA sumB sumC ans = 10000 ans 10000 for sA,sB,sC in bambuu:
    if sA[0]>0 and sB[0]>0 and sC[0]>0:
        mp_total = abs(A-sA[0])+abs(B-sB[0])+abs(C-sC[0])+sA[1]+sB[1]+sC[1]
        if mp_total < ans:
            #record = [sA,sB,sC]
            ans = mp_total
#print(record) sA sB sC bambuu if sA[0]>0 and sB[0]>0 and sC[0]>0:
        mp_total = abs(A-sA[0])+abs(B-sB[0])+abs(C-sC[0])+sA[1]+sB[1]+sC[1]
        if mp_total < ans:
            #record = [sA,sB,sC]
            ans = mp_total
#print(record) sA[0]>0 and sB[0]>0 and sC[0]>0 sA[0]>0 and sB[0]>0 sA[0]>0 sA[0] sA 0 0 sB[0]>0 sB[0] sB 0 0 sC[0]>0 sC[0] sC 0 0 mp_total = abs(A-sA[0])+abs(B-sB[0])+abs(C-sC[0])+sA[1]+sB[1]+sC[1] mp_total abs(A-sA[0])+abs(B-sB[0])+abs(C-sC[0])+sA[1]+sB[1]+sC[1] abs(A-sA[0])+abs(B-sB[0])+abs(C-sC[0])+sA[1]+sB[1] abs(A-sA[0])+abs(B-sB[0])+abs(C-sC[0])+sA[1] abs(A-sA[0])+abs(B-sB[0])+abs(C-sC[0]) abs(A-sA[0])+abs(B-sB[0]) abs(A-sA[0]) abs A-sA[0] A sA[0] sA 0 abs(B-sB[0]) abs B-sB[0] B sB[0] sB 0 abs(C-sC[0]) abs C-sC[0] C sC[0] sC 0 sA[1] sA 1 sB[1] sB 1 sC[1] sC 1 if mp_total < ans:
            #record = [sA,sB,sC]
            ans = mp_total
#print(record) mp_total < ans mp_total ans ans = mp_total ans mp_total print(ans) print ans bambuu = [[0,0,0] for _ in range(4**N)] [[0,0,0] for _ in range(4**N)] bambuu sumC = [sum(lisC),(len(lisC)-1)*10] [sum(lisC),(len(lisC)-1)*10] sumC lisB = [L[j] for j in range(N) if pro[j]=='B'] [L[j] for j in range(N) if pro[j]=='B'] lisB lisC = [L[j] for j in range(N) if pro[j]=='C'] [L[j] for j in range(N) if pro[j]=='C'] lisC ans = 10000 10000 ans B, C = map(int, input().split()) map(int, input().split()) B ans = mp_total mp_total ans N, A, B, C = map(int, input().split()) map(int, input().split()) N A, B, C = map(int, input().split()) map(int, input().split()) A C = map(int, input().split()) map(int, input().split()) C mp_total = abs(A-sA[0])+abs(B-sB[0])+abs(C-sC[0])+sA[1]+sB[1]+sC[1] abs(A-sA[0])+abs(B-sB[0])+abs(C-sC[0])+sA[1]+sB[1]+sC[1] mp_total lisA = [L[j] for j in range(N) if pro[j]=='A'] [L[j] for j in range(N) if pro[j]=='A'] lisA sumB = [sum(lisB),(len(lisB)-1)*10] [sum(lisB),(len(lisB)-1)*10] sumB L = [0]*N [0]*N L sumA = [sum(lisA),(len(lisA)-1)*10] [sum(lisA),(len(lisA)-1)*10] sumA
N, A, B, C = map(int, input().split())
L = [0]*N
for i in range(N):
  L[i] = int(input())

import itertools
bambuu = [[0,0,0] for _ in range(4**N)]
for i,pro in enumerate(itertools.product(['A','B',"C",'D'], repeat=N)):
    lisA = [L[j] for j in range(N) if pro[j]=='A']
    lisB = [L[j] for j in range(N) if pro[j]=='B']
    lisC = [L[j] for j in range(N) if pro[j]=='C']
    sumA = [sum(lisA),(len(lisA)-1)*10]
    sumB = [sum(lisB),(len(lisB)-1)*10]
    sumC = [sum(lisC),(len(lisC)-1)*10]
    bambuu[i-1] = [sumA,sumB,sumC]

ans = 10000
for sA,sB,sC in bambuu:
    if sA[0]>0 and sB[0]>0 and sC[0]>0:
        mp_total = abs(A-sA[0])+abs(B-sB[0])+abs(C-sC[0])+sA[1]+sB[1]+sC[1]
        if mp_total < ans:
            #record = [sA,sB,sC]
            ans = mp_total
#print(record)
print(ans)
#print(*ans, sep='\n')