n,A,B,C = map(int,input().split())

list=[A, B, C]
list_s=[A, B, C]
l = []
mp = 0

for i in range(n):
	l.append(int(input()))
	l.sort()

for i in list:
	if l.count(i) > 0:
		l.remove(i)
		list_s.remove(i)
		continue
	elif l[0] > i:
		mp = mp + (l[0]-i)
		l.remove(l[0])
		list_s.remove(i)
		continue
	for j in l:
		if i - j <= 10:
			mp = mp + (i - j)
			l.remove(j)
			list_s.remove(i)
			break

for i in list_s:
	if len(l)-len(list_s)>=1 and l[0]+l[1]>i and l[0]+l[1]-i <= i-l[0]+10:
		mp = mp + (l[0]+l[1]-i) + 10
		l_0, l_1 = l[0], l[1]
		l.remove(l_0)
		l.remove(l_1)
	elif len(l)-len(list_s)>=2 and l[0]+l[1]+l[2]>i and l[0]+l[1]+l[2]-i < i-l[0]+20:
		mp = mp + (l[0]+l[1]+l[2]-i) + 20
		l_0, l_1, l_2 = l[0], l[1], l[2]
		l.remove(l_0)
		l.remove(l_1)
		l.remove(l_2)
	elif len(l)-len(list_s)>=3 and l[0]+l[1]+l[2]+l[3]>i and l[0]+l[1]+l[2]+l[3]-i < i-l[0]+30:
		mp = mp + (l[0]+l[1]+l[2]+l[3]-i) + 30
		l_0, l_1, l_2, l_3 = l[0], l[1], l[2], l[3]
		l.remove(l_0)
		l.remove(l_1)
		l.remove(l_2)
		l.remove(l_3)
	elif len(l)-len(list_s)>=4 and l[0]+l[1]+l[2]+l[3]+l[4]>i and l[0]+l[1]+l[2]+l[3]+l[4]-i < i-l[0]+40:
		mp = mp + (l[0]+l[1]+l[2]+l[3]+l[4]-i) + 40
		l_0, l_1, l_2, l_3, l_4 = l[0], l[1], l[2], l[3], l[4]
		l.remove(l_0)
		l.remove(l_1)
		l.remove(l_2)
		l.remove(l_3)
		l.remove(l_4)
	elif len(l)-len(list_s)>=5 and l[0]+l[1]+l[2]+l[3]+l[4]+l[5]>i and l[0]+l[1]+l[2]+l[3]+l[4]+l[5]-i < i-l[0]+50:
		mp = mp + (l[0]+l[1]+l[2]-l[3]+l[4]+l[5]-i) + 50
		l_0, l_1, l_2, l_3, l_4, l_5 = l[0], l[1], l[2], l[3], l[4], l[5]
		l.remove(l_0)
		l.remove(l_1)
		l.remove(l_2)
		l.remove(l_3)
		l.remove(l_4)
		l.remove(l_5)
	else:
		mp = mp + (i-l[0])
		l.remove(l[0])

print(mp)