def abc119_c():
  n, a, b, c = map(int, input().split())
  L = [int(input()) for _ in range(n)]
  ans = 10**9

  def dfs(arr):
    if len(arr) == n:
      # ABCともに材料が1つ以上あるなら得点計算する
      if arr.count(1) > 0 and arr.count(2) > 0 and arr.count(3) > 0:
        calc_score(arr)
      return
    for i in range(4):
      dfs(arr + [i])

  def calc_score(arr):
    nonlocal ans
    # パターンにあわせて棒を用意する
    tools_a = [L[i] for i in range(n) if arr[i] == 1]
    tools_b = [L[i] for i in range(n) if arr[i] == 2]
    tools_c = [L[i] for i in range(n) if arr[i] == 3]
    # 得点計算して答えを更新
    score = magic(tools_a, a)
    score += magic(tools_b, b)
    score += magic(tools_c, c)
    ans = min(score, ans)

  def magic(tools, target):
    # 延長短縮で長さ合わせにいく
    pt = abs(target - sum(tools))
    # 棒が複数あると合成コスト追加、棒の数マイナス1
    if len(tools) >= 2:
      pt += 10 * (len(tools) - 1)
    return pt

  dfs([])
  print(ans)

abc119_c() def abc119_c():
  n, a, b, c = map(int, input().split())
  L = [int(input()) for _ in range(n)]
  ans = 10**9

  def dfs(arr):
    if len(arr) == n:
      # ABCともに材料が1つ以上あるなら得点計算する
      if arr.count(1) > 0 and arr.count(2) > 0 and arr.count(3) > 0:
        calc_score(arr)
      return
    for i in range(4):
      dfs(arr + [i])

  def calc_score(arr):
    nonlocal ans
    # パターンにあわせて棒を用意する
    tools_a = [L[i] for i in range(n) if arr[i] == 1]
    tools_b = [L[i] for i in range(n) if arr[i] == 2]
    tools_c = [L[i] for i in range(n) if arr[i] == 3]
    # 得点計算して答えを更新
    score = magic(tools_a, a)
    score += magic(tools_b, b)
    score += magic(tools_c, c)
    ans = min(score, ans)

  def magic(tools, target):
    # 延長短縮で長さ合わせにいく
    pt = abs(target - sum(tools))
    # 棒が複数あると合成コスト追加、棒の数マイナス1
    if len(tools) >= 2:
      pt += 10 * (len(tools) - 1)
    return pt

  dfs([])
  print(ans) abc119_c n, a, b, c = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split a b c int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input L = [int(input()) for _ in range(n)] L [int(input()) for _ in range(n)] ans = 10**9 ans 10**9 10 9 def dfs(arr):
    if len(arr) == n:
      # ABCともに材料が1つ以上あるなら得点計算する
      if arr.count(1) > 0 and arr.count(2) > 0 and arr.count(3) > 0:
        calc_score(arr)
      return
    for i in range(4):
      dfs(arr + [i])

   dfs if len(arr) == n:
      # ABCともに材料が1つ以上あるなら得点計算する
      if arr.count(1) > 0 and arr.count(2) > 0 and arr.count(3) > 0:
        calc_score(arr)
      return
     len(arr) == n len(arr) len arr n if arr.count(1) > 0 and arr.count(2) > 0 and arr.count(3) > 0:
        calc_score(arr)
       arr.count(1) > 0 and arr.count(2) > 0 and arr.count(3) > 0 arr.count(1) > 0 and arr.count(2) > 0 arr.count(1) > 0 arr.count(1) arr.count arr count 1 0 arr.count(2) > 0 arr.count(2) arr.count arr count 2 0 arr.count(3) > 0 arr.count(3) arr.count arr count 3 0 calc_score(arr) calc_score arr return for i in range(4):
      dfs(arr + [i])

   i range(4) range 4 dfs(arr + [i]) dfs arr + [i] arr [i] i arr arr def calc_score(arr):
    nonlocal ans
    # パターンにあわせて棒を用意する
    tools_a = [L[i] for i in range(n) if arr[i] == 1]
    tools_b = [L[i] for i in range(n) if arr[i] == 2]
    tools_c = [L[i] for i in range(n) if arr[i] == 3]
    # 得点計算して答えを更新
    score = magic(tools_a, a)
    score += magic(tools_b, b)
    score += magic(tools_c, c)
    ans = min(score, ans)

   calc_score nonlocal ans L[i] for i in range(n) if arr[i] == 1 for i in range(n) if arr[i] == 1 i range(n) range n arr[i] == 1 arr[i] arr i 1 if arr[i] == 1 L[i] L i tools_a = [L[i] for i in range(n) if arr[i] == 1] tools_a [L[i] for i in range(n) if arr[i] == 1] L[i] for i in range(n) if arr[i] == 2 for i in range(n) if arr[i] == 2 i range(n) range n arr[i] == 2 arr[i] arr i 2 if arr[i] == 2 L[i] L i tools_b = [L[i] for i in range(n) if arr[i] == 2] tools_b [L[i] for i in range(n) if arr[i] == 2] L[i] for i in range(n) if arr[i] == 3 for i in range(n) if arr[i] == 3 i range(n) range n arr[i] == 3 arr[i] arr i 3 if arr[i] == 3 L[i] L i tools_c = [L[i] for i in range(n) if arr[i] == 3] tools_c [L[i] for i in range(n) if arr[i] == 3] score = magic(tools_a, a) score magic(tools_a, a) magic tools_a a score += magic(tools_b, b) score magic(tools_b, b) magic tools_b b score += magic(tools_c, c) score magic(tools_c, c) magic tools_c c ans = min(score, ans) ans min(score, ans) min score ans arr arr def magic(tools, target):
    # 延長短縮で長さ合わせにいく
    pt = abs(target - sum(tools))
    # 棒が複数あると合成コスト追加、棒の数マイナス1
    if len(tools) >= 2:
      pt += 10 * (len(tools) - 1)
    return pt

   magic pt = abs(target - sum(tools)) pt abs(target - sum(tools)) abs target - sum(tools) target sum(tools) sum tools if len(tools) >= 2:
      pt += 10 * (len(tools) - 1)
     len(tools) >= 2 len(tools) len tools 2 pt += 10 * (len(tools) - 1) pt 10 * (len(tools) - 1) 10 len(tools) - 1 len(tools) len tools 1 return pt pt tools tools target target dfs([]) dfs [] print(ans) print ans abc119_c() abc119_c def abc119_c():
  n, a, b, c = map(int, input().split())
  L = [int(input()) for _ in range(n)]
  ans = 10**9

  def dfs(arr):
    if len(arr) == n:
      # ABCともに材料が1つ以上あるなら得点計算する
      if arr.count(1) > 0 and arr.count(2) > 0 and arr.count(3) > 0:
        calc_score(arr)
      return
    for i in range(4):
      dfs(arr + [i])

  def calc_score(arr):
    nonlocal ans
    # パターンにあわせて棒を用意する
    tools_a = [L[i] for i in range(n) if arr[i] == 1]
    tools_b = [L[i] for i in range(n) if arr[i] == 2]
    tools_c = [L[i] for i in range(n) if arr[i] == 3]
    # 得点計算して答えを更新
    score = magic(tools_a, a)
    score += magic(tools_b, b)
    score += magic(tools_c, c)
    ans = min(score, ans)

  def magic(tools, target):
    # 延長短縮で長さ合わせにいく
    pt = abs(target - sum(tools))
    # 棒が複数あると合成コスト追加、棒の数マイナス1
    if len(tools) >= 2:
      pt += 10 * (len(tools) - 1)
    return pt

  dfs([])
  print(ans) def abc119_c():
  n, a, b, c = map(int, input().split())
  L = [int(input()) for _ in range(n)]
  ans = 10**9

  def dfs(arr):
    if len(arr) == n:
      # ABCともに材料が1つ以上あるなら得点計算する
      if arr.count(1) > 0 and arr.count(2) > 0 and arr.count(3) > 0:
        calc_score(arr)
      return
    for i in range(4):
      dfs(arr + [i])

  def calc_score(arr):
    nonlocal ans
    # パターンにあわせて棒を用意する
    tools_a = [L[i] for i in range(n) if arr[i] == 1]
    tools_b = [L[i] for i in range(n) if arr[i] == 2]
    tools_c = [L[i] for i in range(n) if arr[i] == 3]
    # 得点計算して答えを更新
    score = magic(tools_a, a)
    score += magic(tools_b, b)
    score += magic(tools_c, c)
    ans = min(score, ans)

  def magic(tools, target):
    # 延長短縮で長さ合わせにいく
    pt = abs(target - sum(tools))
    # 棒が複数あると合成コスト追加、棒の数マイナス1
    if len(tools) >= 2:
      pt += 10 * (len(tools) - 1)
    return pt

  dfs([])
  print(ans) abc119_c
def abc119_c():
  n, a, b, c = map(int, input().split())
  L = [int(input()) for _ in range(n)]
  ans = 10**9

  def dfs(arr):
    if len(arr) == n:
      # ABCともに材料が1つ以上あるなら得点計算する
      if arr.count(1) > 0 and arr.count(2) > 0 and arr.count(3) > 0:
        calc_score(arr)
      return
    for i in range(4):
      dfs(arr + [i])

  def calc_score(arr):
    nonlocal ans
    # パターンにあわせて棒を用意する
    tools_a = [L[i] for i in range(n) if arr[i] == 1]
    tools_b = [L[i] for i in range(n) if arr[i] == 2]
    tools_c = [L[i] for i in range(n) if arr[i] == 3]
    # 得点計算して答えを更新
    score = magic(tools_a, a)
    score += magic(tools_b, b)
    score += magic(tools_c, c)
    ans = min(score, ans)

  def magic(tools, target):
    # 延長短縮で長さ合わせにいく
    pt = abs(target - sum(tools))
    # 棒が複数あると合成コスト追加、棒の数マイナス1
    if len(tools) >= 2:
      pt += 10 * (len(tools) - 1)
    return pt

  dfs([])
  print(ans)

abc119_c()