import itertools

def calc(t, l):
	ti = 0
	min_mp = 0
	while ti < 3:
		mp = float('inf')
		op = None
		for i in range(len(l)):
			if l[i] == t[ti]:
				l.pop(i)
				ti += 1
				break
			if 0 < t[ti] - l[i] < mp:
				mp = t[ti] - l[i]
				op = ('a', i)
			if 0 < l[i] - t[ti] < mp:
				mp = l[i] - t[ti]
				op = ('d', i)
			if len(l) > 3 - ti:
				for j in range(i + 1, len(l)):
					if abs(t[ti] - l[i] - l[j]) + 10 < mp:
						mp = abs(t[ti] - l[i] - l[j]) + 10
						op = ('m', i, j)
		else:
			if op[0] == 'a':
				l[op[1]] += 1
				min_mp += 1
			elif op[0] == 'd':
				l[op[1]] -= 1
				min_mp += 1
			else:
				l[op[1]] += l[op[2]]
				l.pop(op[2])
				min_mp += 10
	return min_mp


N, A, B, C = [int(v) for v in input().split()]
l = [int(input()) for _ in range(N)]
t = (A, B, C)
min_mp = float('inf')
for tp in itertools.permutations(t):
	min_mp = min(min_mp, calc(tp, l[:]))
print(min_mp)