
from itertools import combinations
from copy import deepcopy

# class Kadomatsu:
#   def __init__(self, length, cost):
#     self.length = length
#     self.cost = cost
  
#   def __str__(self):
#     return "Kadomatsu(length={0}, cost={1})".format(self.length, self.cost)
  
#   def __repr__(self):
#     return self.__str__()

def parse():
  N, A, B, C = map(int, input().split(" "))
  L = []
  for n in range(N):
    L.append(int(input()))
  return N, A, B, C, L

def main():
  N, A, B, C, L = parse()
  # print(N, A, B, C, L)

  # 門松セットの初期化
  kadomatsu_set_list = []
  kadomatsu_set = []
  cost_zero = [0, 0, 0]
  for l in L:
    if A == l: cost_zero[0] = 1
    elif B == l: cost_zero[1] = 1
    elif C == l: cost_zero[2] = 1
    kadomatsu_set.append((l, 0))
    # kadomatsu_set.append(Kadomatsu(l, 0))
  kadomatsu_set_list.append(kadomatsu_set)
  # print(kadomatsu_set_list)

  # 初期状態でコスト0の組み合わせがある場合
  if sum(cost_zero) == 3:
    print(0)
    exit(0)

  # kadomatsu_set_list > 3の時，合成可能なので，
  # 合成可能な場合，合成を繰り返す
  i = 0
  while len(kadomatsu_set_list[i]) > 3:
    for combination in combinations(kadomatsu_set_list[i], 2):
      # print("combination:", combination)
      new_kadomastu = (combination[0][0] + combination[1][0], 
        combination[0][1] + combination[1][1] + 10)
      # new_kadomastu = Kadomatsu(combination[0].length + combination[1].length, 
      #   combination[0].cost + combination[1].cost + 10)
      
      # new_kadomastu_setの初期化
      new_kadomastu_set = [kadomatsu for kadomatsu in kadomatsu_set_list[i]]
      new_kadomastu_set.remove(combination[0])
      new_kadomastu_set.remove(combination[1])
      
      # new_kadomastu_set = [kadomatsu for kadomatsu in kadomatsu_set_list[i]
      #   if (not kadomatsu is combination[0]) and (not kadomatsu is combination[1])]
      
      # new_kadomastu_set = []
      # for kadomatsu in kadomatsu_set_list[i]:
      #   if kadomatsu is combination[0] or kadomatsu is combination[1]: continue
      #   new_kadomastu_set.append(kadomatsu)
      new_kadomastu_set.append(new_kadomastu)
      # print("new_kadomastu_set:", new_kadomastu_set)
      # input()

      kadomatsu_set_list.append(new_kadomastu_set)

    i += 1
  
  # print(len(kadomatsu_set_list))
  min_cost = 10 ** 20
  for kadomatsu_set in kadomatsu_set_list:
    # print(kadomatsu_set)

    # Aに最も長さが近い門松を探す
    min_diff_A = 10 ** 10
    min_diff_A_i = 0
    for i, kadomatsu in enumerate(kadomatsu_set):
      diff = abs(A - kadomatsu[0])
      # diff = abs(A - kadomatsu.length)
      if min_diff_A > diff:
        min_diff_A = diff
        min_diff_A_i = i

    # Bに最も長さが近い門松を探す
    min_diff_B = 10 ** 10
    min_diff_B_i = 0
    for i, kadomatsu in enumerate(kadomatsu_set):
      if i == min_diff_A_i: continue  # Aですでに選んでいる門松はスキップ
      diff = abs(B - kadomatsu[0])
      # diff = abs(B - kadomatsu.length)
      if min_diff_B > diff:
        min_diff_B = diff
        min_diff_B_i = i
    
    # Cに最も長さが近い門松を探す
    min_diff_C = 10 ** 10
    min_diff_C_i = 0
    for i, kadomatsu in enumerate(kadomatsu_set):
      if i == min_diff_A_i: continue  # Aですでに選んでいる門松はスキップ
      if i == min_diff_B_i: continue  # Bですでに選んでいる門松はスキップ
      diff = abs(C - kadomatsu[0])
      # diff = abs(C - kadomatsu.length)
      if min_diff_C > diff:
        min_diff_C = diff
        min_diff_C_i = i
    
    cost = min_diff_A + min_diff_B + min_diff_C \
      + kadomatsu_set[min_diff_A_i][1] + kadomatsu_set[min_diff_B_i][1] + kadomatsu_set[min_diff_C_i][1]
      # + kadomatsu_set[min_diff_A_i].cost + kadomatsu_set[min_diff_B_i].cost + kadomatsu_set[min_diff_C_i].cost
    if min_cost > cost: min_cost = cost
    if min_cost == 0: # コスト0の時点で最小値のため即終了
      print(0)
      exit(0)
    # print(min_diff_A_i, min_diff_B_i, min_diff_C_i, cost)
    # input()
  print(min_cost)


if __name__ == "__main__":
  main()