num, a, b, c = input().split()
num = int(num)

targetList = ([int(a), int(b), int(c)])
list = list()

mp = 0

for i in range(num) :
    list.append(int(input()))

for target in targetList :
    for elem in list :
        if elem == target :
            list.remove(elem)
            targetList.remove(target)

for target in targetList :
    for elem in list :
        if elem - target >= -10 and elem - target < 0:
            mp += target - elem
            list.remove(elem)
            targetList.remove(target)
        elif elem - target <= 10 and elem - target > 0:
            mp += elem - target
            list.remove(elem)
            targetList.remove(target)

for target in targetList :
    min = 100
    savedMin = 100
    buf1 = 0
    buf2 = 0
    buf3 = 0
    while True :
        for elem in list :
            for elem2 in list :
                if elem + elem2 - target < min and elem + elem2 - target > - min:
                    min = elem + elem2 - target
                    buf1 = elem
                    buf2 = elem2
        if savedMin == min :
            break
        list.append(buf1+buf2)
        list.remove(buf1)
        targetList.remove(buf2)
        buf3 = buf1 + buf2
        mp += 10
        if min >= -10 and min <= 10 :
            break
        savedMin = min
    if buf3 - target < 0 :
        mp+= buf3 - target
        list.remove(buf3)
        targetList.remove(target)
    if buf3 - target > 0 :
        mp+= target - buf3
        list.remove(buf3)
        targetList.remove(target)
    if buf3 - target == 0 :
        list.remove(buf3)
        targetList.remove(target)




print(mp)
