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

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



min_cost = 10 ** 18



def func(n, select):

	global min_cost

	if n == 0:

		if len(set(select) - {0}) < 3:

			return

		#print(select)

		cost = 0

		a, b, c = 0, 0, 0

		for i, t in enumerate(select):

			if t == 1:

				if a != 0:

					cost += 10

				a += L[i]

			if t == 2:

				if b != 0:

					cost += 10

				b += L[i]

			if t == 3:

				if c != 0:

					cost += 10

				c += L[i]

		cost += abs(A - a)

		cost += abs(B - b)

		cost += abs(C - c)

		min_cost = min(min_cost, cost)

		return

	for i in range(4):

		func(n - 1, select + [i])



func(N, [])

print(min_cost)

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

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



INF = 10 ** 12



def solve(n, cost, a, b, c):

	if n == N:

		if 0 == min(a, b, c):

			return INF

		return abs(a - A) + abs(b - B) + abs(c - C) + cost - 30

	ret1 = solve(n + 1, cost, a, b, c)

	ret2 = solve(n + 1, cost + 10, a + L[n], b, c)

	ret3 = solve(n + 1, cost + 10, a, b + L[n], c)

	ret4 = solve(n + 1, cost + 10, a, b, c + L[n])

	return min(ret1, ret2, ret3, ret4)



print((solve(0, 0, 0, 0, 0)))

N, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(N)]
min_cost = 10**18


def func(n, select):
    global min_cost
    if n == 0:
        if len(set(select) - {0}) < 3:
            return
        # print(select)
        cost = 0
        a, b, c = 0, 0, 0
        for i, t in enumerate(select):
            if t == 1:
                if a != 0:
                    cost += 10
                a += L[i]
            if t == 2:
                if b != 0:
                    cost += 10
                b += L[i]
            if t == 3:
                if c != 0:
                    cost += 10
                c += L[i]
        cost += abs(A - a)
        cost += abs(B - b)
        cost += abs(C - c)
        min_cost = min(min_cost, cost)
        return
    for i in range(4):
        func(n - 1, select + [i])


func(N, [])
print(min_cost)

N, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(N)]
INF = 10**12


def solve(n, cost, a, b, c):
    if n == N:
        if 0 == min(a, b, c):
            return INF
        return abs(a - A) + abs(b - B) + abs(c - C) + cost - 30
    ret1 = solve(n + 1, cost, a, b, c)
    ret2 = solve(n + 1, cost + 10, a + L[n], b, c)
    ret3 = solve(n + 1, cost + 10, a, b + L[n], c)
    ret4 = solve(n + 1, cost + 10, a, b, c + L[n])
    return min(ret1, ret2, ret3, ret4)


print((solve(0, 0, 0, 0, 0)))

-min_cost = 10**18 +INF = 10**12 -def func(n, select): -    global min_cost -    if n == 0: -        if len(set(select) - {0}) < 3: -            return -        # print(select) -        cost = 0 -        a, b, c = 0, 0, 0 -        for i, t in enumerate(select): -            if t == 1: -                if a != 0: -                    cost += 10 -                a += L[i] -            if t == 2: -                if b != 0: -                    cost += 10 -                b += L[i] -            if t == 3: -                if c != 0: -                    cost += 10 -                c += L[i] -        cost += abs(A - a) -        cost += abs(B - b) -        cost += abs(C - c) -        min_cost = min(min_cost, cost) -        return -    for i in range(4): -        func(n - 1, select + [i]) +def solve(n, cost, a, b, c): +    if n == N: +        if 0 == min(a, b, c): +            return INF +        return abs(a - A) + abs(b - B) + abs(c - C) + cost - 30 +    ret1 = solve(n + 1, cost, a, b, c) +    ret2 = solve(n + 1, cost + 10, a + L[n], b, c) +    ret3 = solve(n + 1, cost + 10, a, b + L[n], c) +    ret4 = solve(n + 1, cost + 10, a, b, c + L[n]) +    return min(ret1, ret2, ret3, ret4) -func(N, []) -print(min_cost) +print((solve(0, 0, 0, 0, 0)))