n, a, b, c = map(int, input().split())
L = [int(input()) for _ in range(n)]
mp = 0
def use(n, d):
  bit = [[0]*n for i in range(2**n)]
  for i in range(2**n):
    for j in range(n):
      if i&(2**j) > 0:
        bit[i][j] = 1
  cl = []
  for i in range(2**n):
    s = 0
    for j in range(n):
      s += L[j] * bit[i][j]
    cl.append(s)
  cmin = 999999
  for i in range(1, 2**n):
    if abs(cl[i] - d) < cmin:
      cmin = abs(cl[i] - d)
      cindex = i
  ng = []
  use = []
  for j in range(n):
    if bit[cindex][j]:
      use.append(L[j])
      if L[j] < 10:
        ng.append(L[j])
  for x in use:
    L.remove(x)
  if sum(bit[cindex]):
     return cmin
  else:
    return sum(bit[cindex]) * 10 - 10 + cmin - 10 * len(ng) + sum(ng)
mp += use(n, c)
n = len(L)
mp += use(n, b)
n = len(L)
mp += use(n, a)
print(mp)