NABC = input().split()

N = int(NABC[0])
ABC = []
ABC.append( int(NABC[3]) )
ABC.append( int(NABC[2]) )
ABC.append( int(NABC[1]) )
MP = 0

Tlist = []
for lop in range(N):
    l = int(input())
    Tlist.append(l)

Tlist = sorted(Tlist)

if ABC[2] in Tlist:
    Tlist.pop(Tlist.index(ABC[2]))
    ABC.pop(2)
if ABC[1] in Tlist:
    Tlist.pop(Tlist.index(ABC[1]))
    ABC.pop(1)
if ABC[0] in Tlist:
    Tlist.pop(Tlist.index(ABC[0]))
    ABC.pop(0)

if len(ABC) == 3:
    if ABC[2] < Tlist[0]:
        MP = MP + (Tlist[0] - ABC[2])
        ABC.pop(2)
        Tlist.pop(0)
if len(ABC) >= 2:
    if ABC[1] < Tlist[0]:
        MP = MP + (Tlist[0] - ABC[1])
        ABC.pop(1)
        Tlist.pop(0)
if len(ABC) >= 1:
    if ABC[0] < Tlist[0]:
        MP = MP + (Tlist[0] - ABC[0])
        ABC.pop(0)
        Tlist.pop(0)

ABC = sorted(ABC)
while(True):
    if ABC == []:
        break
    take = ABC[0]
    if take < Tlist[0]:
        MP = MP + (Tlist[0] - take)
        ABC.pop(0)
        Tlist.pop(0)
    else:
        sa = 1000
        Tindex = -1
        for lop in range(len(Tlist)):
            if abs(take - Tlist[lop]) < sa:
                Tindex = lop
                sa = abs(take - Tlist[lop])
        if sa < 10:
            Tlist.pop(Tindex)
            ABC.pop(0)
            MP = MP + sa
        else:
            sa2 = 10000
            maeI = -1
            atoI = -1
            for lop in range(len(Tlist)):
                mae = Tlist[lop]
                for lop2 in range(len(Tlist)):
                    if not(lop == lop2):
                        ato = Tlist[lop2]
                        if abs(take - (mae + ato)) < sa2:
                            maeI = lop
                            atoI = lop2
                            sa2 = abs(take - (mae + ato))
            if sa > sa2 + 10:
                MP += 10
                if maeI > atoI:
                    Tlist.append(Tlist[maeI] + Tlist[atoI])
                    Tlist.pop(maeI)
                    Tlist.pop(atoI)
                    Tlist = sorted(Tlist)  
                else:
                    Tlist.append(Tlist[maeI] + Tlist[atoI])
                    Tlist.pop(atoI)
                    Tlist.pop(maeI)
                    Tlist = sorted(Tlist)
            else:
                Tlist.pop(Tindex)
                ABC.pop(0)
                MP = MP + sa
    
print(MP)
