def f(x):
  q, r = divmod(x, 4)
  if q:
    return f(q) + str(r)
  return str(r)
n, *abc = map(int, input().split())
L = [ int(input()) for _ in range(n) ]
ans = float("inf")
for i in range(4**n):
  T = [set(), set(), set()]
  s = f(i)
  s = "0"*(n-len(s)) + s
  if {"0", "1", "2"} <= set(s):
    for j in range(n):
      if s[j] != "3":
        T[int(s[j])].add(L[j])
    temp = 0
    for j in range(3):
      l = len(T[j])
      temp += 10*(l-1) + abs(sum(T[j])-abc[j])
    ans = min(ans, temp)
print(ans)