import numpy as np
n, a, b, c = (int(i) for i in input().split())
l = [int(input()) for i in range(n)]
if n == 3:
  l = np.array(l)
  lc = np.min(abs(l-c))
  lb = np.min(abs(l-b))
  la = np.min(abs(l-a))
  ans = lc+lb+la
else:
  ans = 100
print(ans)
  