n, a, b, c = list(map(int, input().split()))

take = []



for i in range(n):

    t = int(eval(input()))

    take.append(t)



def Base_10_to_n(X, n):

    X_dumy = X

    out = ''

    while X_dumy>0:

        out = str(X_dumy%n)+out

        X_dumy = int(X_dumy/n)

    return out



def cal_cost(li, a):

    if li == []:

        return 10**12

    co = 0

    if len(li) == 1:

        co += abs(li[0] - a)

    else:

        co += abs(sum(li) - a)

        co += (len(li) - 1) * 10

    return co



min_cost = 10**12

for i in range(4**n):

    cost = 0

    num = Base_10_to_n(i, 4).zfill(n)

    for_A = []

    for_B = []

    for_C = []

    for j in range(n):

        if num[j] == '1':

            for_A.append(take[j])

        elif num[j] == '2':

            for_B.append(take[j])

        elif num[j] == '3':

            for_C.append(take[j])

    cost += cal_cost(for_A, a)

    cost += cal_cost(for_B, b)

    cost += cal_cost(for_C, c)

    if cost < min_cost:

        min_cost = cost



print(min_cost)

n, a, b, c = list(map(int, input().split()))

bamboos = []

for i in range(n):

    bamboo = int(eval(input()))

    bamboos.append(bamboo)



def Base_10_to_n(X, n):

    X_dumy = X

    out = ''

    while X_dumy>0:

        out = str(X_dumy%n)+out

        X_dumy = int(X_dumy/n)

    return out



def calc_score(group, target):

    score = 0

    if len(group) > 1:

        score += 10 * (len(group) - 1)

    length = sum(group)

    score += abs(length - target)

    return score



min_score = 10**12

for i in range(4**n):

    num = Base_10_to_n(i, 4).zfill(n)

    score = 0

    group_A = []

    group_B = []

    group_C = []

    for j in range(n):

        if num[j] == '1':

            group_A.append(bamboos[j])

        elif num[j] == '2':

            group_B.append(bamboos[j])

        elif num[j] == '3':

            group_C.append(bamboos[j])

    if len(group_A) == 0 or len(group_B) == 0 or len(group_C) == 0:

        continue

    else:

        score += calc_score(group_A, a)

        score += calc_score(group_B, b)

        score += calc_score(group_C, c)



    if score < min_score:

        min_score = score



print(min_score)
n, a, b, c = list(map(int, input().split()))
take = []
for i in range(n):
    t = int(eval(input()))
    take.append(t)


def Base_10_to_n(X, n):
    X_dumy = X
    out = ""
    while X_dumy > 0:
        out = str(X_dumy % n) + out
        X_dumy = int(X_dumy / n)
    return out


def cal_cost(li, a):
    if li == []:
        return 10**12
    co = 0
    if len(li) == 1:
        co += abs(li[0] - a)
    else:
        co += abs(sum(li) - a)
        co += (len(li) - 1) * 10
    return co


min_cost = 10**12
for i in range(4**n):
    cost = 0
    num = Base_10_to_n(i, 4).zfill(n)
    for_A = []
    for_B = []
    for_C = []
    for j in range(n):
        if num[j] == "1":
            for_A.append(take[j])
        elif num[j] == "2":
            for_B.append(take[j])
        elif num[j] == "3":
            for_C.append(take[j])
    cost += cal_cost(for_A, a)
    cost += cal_cost(for_B, b)
    cost += cal_cost(for_C, c)
    if cost < min_cost:
        min_cost = cost
print(min_cost)

n, a, b, c = list(map(int, input().split()))
bamboos = []
for i in range(n):
    bamboo = int(eval(input()))
    bamboos.append(bamboo)


def Base_10_to_n(X, n):
    X_dumy = X
    out = ""
    while X_dumy > 0:
        out = str(X_dumy % n) + out
        X_dumy = int(X_dumy / n)
    return out


def calc_score(group, target):
    score = 0
    if len(group) > 1:
        score += 10 * (len(group) - 1)
    length = sum(group)
    score += abs(length - target)
    return score


min_score = 10**12
for i in range(4**n):
    num = Base_10_to_n(i, 4).zfill(n)
    score = 0
    group_A = []
    group_B = []
    group_C = []
    for j in range(n):
        if num[j] == "1":
            group_A.append(bamboos[j])
        elif num[j] == "2":
            group_B.append(bamboos[j])
        elif num[j] == "3":
            group_C.append(bamboos[j])
    if len(group_A) == 0 or len(group_B) == 0 or len(group_C) == 0:
        continue
    else:
        score += calc_score(group_A, a)
        score += calc_score(group_B, b)
        score += calc_score(group_C, c)
    if score < min_score:
        min_score = score
print(min_score)

-take = [] +bamboos = [] -    t = int(eval(input())) -    take.append(t) +    bamboo = int(eval(input())) +    bamboos.append(bamboo) -def cal_cost(li, a): -    if li == []: -        return 10**12 -    co = 0 -    if len(li) == 1: -        co += abs(li[0] - a) -    else: -        co += abs(sum(li) - a) -        co += (len(li) - 1) * 10 -    return co +def calc_score(group, target): +    score = 0 +    if len(group) > 1: +        score += 10 * (len(group) - 1) +    length = sum(group) +    score += abs(length - target) +    return score -min_cost = 10**12 +min_score = 10**12 -    cost = 0 -    for_A = [] -    for_B = [] -    for_C = [] +    score = 0 +    group_A = [] +    group_B = [] +    group_C = [] -            for_A.append(take[j]) +            group_A.append(bamboos[j]) -            for_B.append(take[j]) +            group_B.append(bamboos[j]) -            for_C.append(take[j]) -    cost += cal_cost(for_A, a) -    cost += cal_cost(for_B, b) -    cost += cal_cost(for_C, c) -    if cost < min_cost: -        min_cost = cost -print(min_cost) +            group_C.append(bamboos[j]) +    if len(group_A) == 0 or len(group_B) == 0 or len(group_C) == 0: +        continue +    else: +        score += calc_score(group_A, a) +        score += calc_score(group_B, b) +        score += calc_score(group_C, c) +    if score < min_score: +        min_score = score +print(min_score)