import itertools



N, A, B, C = list(map(int, input().split()))

L = [int(eval(input())) for i in range(N)]



def min_cost(target, l_list):

  if target in l_list:

    return 0

  else:

    res = 1000

    for l in l_list:

      res = min(res, abs(target - l))

    

    for i, l in enumerate(l_list):

      res = min(res, min_cost(target-l, l_list[:i]+l_list[i+1:]) + 10)

  

    return res



ans = 1000 * 3

combs = list(itertools.product([0, 1, 2], repeat=N))

for comb in combs:

  labc = [[], [], []]

  for i, idx in enumerate(comb):

    labc[idx].append(L[i])

  

  la, lb, lc = labc

  if len(la)*len(lb)*len(lc):

    ans = min(ans, min_cost(A, la)+min_cost(B, lb)+min_cost(C, lc))



print(ans)
import itertools



N, A, B, C = list(map(int, input().split()))

L = [int(eval(input())) for i in range(N)]



def min_cost(target, l_list):

  return 10*(len(l_list) - 1) + abs(target - sum(l_list))





ans = 1000 * 3

combs = list(itertools.product([0, 1, 2, 3], repeat=N))

for comb in combs:

  labcn = [[], [], [], []]

  for i, idx in enumerate(comb):

    labcn[idx].append(L[i])

  

  la, lb, lc, ln = labcn

  if len(la)*len(lb)*len(lc):

    ans = min(ans, min_cost(A, la)+min_cost(B, lb)+min_cost(C, lc))



print(ans)
import itertools

N, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for i in range(N)]


def min_cost(target, l_list):
    if target in l_list:
        return 0
    else:
        res = 1000
        for l in l_list:
            res = min(res, abs(target - l))
        for i, l in enumerate(l_list):
            res = min(res, min_cost(target - l, l_list[:i] + l_list[i + 1 :]) + 10)
        return res


ans = 1000 * 3
combs = list(itertools.product([0, 1, 2], repeat=N))
for comb in combs:
    labc = [[], [], []]
    for i, idx in enumerate(comb):
        labc[idx].append(L[i])
    la, lb, lc = labc
    if len(la) * len(lb) * len(lc):
        ans = min(ans, min_cost(A, la) + min_cost(B, lb) + min_cost(C, lc))
print(ans)

import itertools

N, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for i in range(N)]


def min_cost(target, l_list):
    return 10 * (len(l_list) - 1) + abs(target - sum(l_list))


ans = 1000 * 3
combs = list(itertools.product([0, 1, 2, 3], repeat=N))
for comb in combs:
    labcn = [[], [], [], []]
    for i, idx in enumerate(comb):
        labcn[idx].append(L[i])
    la, lb, lc, ln = labcn
    if len(la) * len(lb) * len(lc):
        ans = min(ans, min_cost(A, la) + min_cost(B, lb) + min_cost(C, lc))
print(ans)

-    if target in l_list: -        return 0 -    else: -        res = 1000 -        for l in l_list: -            res = min(res, abs(target - l)) -        for i, l in enumerate(l_list): -            res = min(res, min_cost(target - l, l_list[:i] + l_list[i + 1 :]) + 10) -        return res +    return 10 * (len(l_list) - 1) + abs(target - sum(l_list)) -combs = list(itertools.product([0, 1, 2], repeat=N)) +combs = list(itertools.product([0, 1, 2, 3], repeat=N)) -    labc = [[], [], []] +    labcn = [[], [], [], []] -        labc[idx].append(L[i]) -    la, lb, lc = labc +        labcn[idx].append(L[i]) +    la, lb, lc, ln = labcn