
from itertools import combinations
from copy import deepcopy

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, L = parse()
  # print(N, A, B, C, L)

  # 門松セットの初期化
  kadomatsu_set_list = []
  kadomatsu_set = []
  cost_zero = [0, 0, 0]
  for l in L:
    for i, a in enumerate(A):
      if a == l: cost_zero[i] = 1
    kadomatsu_set.append(l)
    # kadomatsu_set.append((l, 0))
    # kadomatsu_set.append(Kadomatsu(l, 0))
  kadomatsu_set_list.append((kadomatsu_set, 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][0]) > 3:
  # while len(kadomatsu_set_list[i]) > 3:
    for combination in combinations(kadomatsu_set_list[i][0], 2):
    # for combination in combinations(kadomatsu_set_list[i], 2):
      # print("combination:", combination)
      new_kadomastu = combination[0] + combination[1]
      # new_kadomastu = (combination[0][0] + combination[1][0], 
      #   combination[0][1] + combination[1][1] + 10)
      
      # new_kadomastu_setの初期化
      # new_kadomastu_set = [kadomatsu for kadomatsu in kadomatsu_set_list[i][0]]
      # 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 = []
      continued0 = False
      continued1 = False
      for kadomatsu in kadomatsu_set_list[i][0]:
        # if kadomatsu == combination[0] or kadomatsu == combination[1]: continue
        if kadomatsu == combination[0] and not continued0:
          continued0 = True
          continue
        if kadomatsu == combination[1] and not continued1:
          continued1 = True
          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, kadomatsu_set_list[i][1] + 10))
      # kadomatsu_set_list.append(new_kadomastu_set)

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

    cost = set_cost
    # cost = 0
    for a in A:
      min_diff = 10 ** 10
      min_diff_i = 0
      for i, kadomatsu in enumerate(kadomatsu_set):
        diff = abs(a - kadomatsu)
        # diff = abs(a - kadomatsu[0])
        if min_diff > diff:
          min_diff = diff
          min_diff_i = i
      cost += min_diff
      # cost += min_diff + kadomatsu_set[min_diff_i][1]
      if cost > min_cost: # 現時点で最小コストより高い場合はこれ以上探索しない
        # do_skip = True
        break
      kadomatsu_set.remove(kadomatsu_set[min_diff_i])

    # if do_skip: continue

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