# review
import copy
n, a, b, c = map(int, input().split())
lList = []

for _ in range(n) :
        lList.append(int(input()))

lList.sort()
goal = [a, b, c]
goal.sort()

def removed(i,j) :
        goal.remove(i)
        lList.remove(j)

mp = 0
def pick(x, y) : # if same value & goal < lList
        mp = 0
        for i in copy.copy(x) :
                for j in copy.copy(y) :
                        if i == j and i in goal:
                                removed(i,j)
        for i in copy.copy(x) :
                for j in copy.copy(y) :
                        if i < j and i in goal:
                                mp += j - i 
                                removed(i,j)

pick(goal,lList)      


diffList = []
diff = 10
for j in lList :
        for i in goal :
                if abs(i-j) < 10 :
                        diff = min(diff, abs(i-j))
        if diff != 10 :
                diffList.append([diff, i, j])
        diff = 10
for i in diffList :      
        mp += i[0]       
        goal.remove(i[1])
        lList.remove(i[2])

add2 = []
for i in lList :
        for j in lList[i+1:] :
                add2.append(i + j, i, j)
# ------------------------------------------------------
# addList = []
# diff = 10
# for j in add2 :
#         for i in goal :
#                 if abs(i-j[0]) < 10 :
#                         diff = min(diff, abs(i-j[0]))
#         if diff != 10 :
#                 diffList.append([diff, i, j[0]])
#         diff = 10
# for i in diffList :      
#         mp += i[0]       
#         goal.remove(i[1])
#         lList.remove(i[2])


             
print(mp)
