n, A, B, C = (int(i) for i in input().split())

l = [int(eval(input())) for i in range(n)]

a = []

b = []

c = []



def furiwake(x):

    global a

    global b

    global c

    a = []

    b = []

    c = []

    for i in range(1, n+1):

        if dig4(x, i) == 0:

            a.append(l[i-1])

        if dig4(x, i) == 1:

            b.append(l[i-1])

        if dig4(x, i) == 2:

            c.append(l[i-1])



def dig4(n, k):

    return (n%(4**k))//(4**(k-1))



def cost():

    costa = 10 * (len(a)-1) + abs(sum(a)-A)

    costb = 10 * (len(b)-1) + abs(sum(b)-B)

    costc = 10 * (len(c)-1) + abs(sum(c)-C)

    return costa+costb+costc



ans = 1000000000

for i in range(1, 4**8):

    furiwake(i)

    if(len(a)*len(b)*len(c)):

        ans = min(ans, cost())

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

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

INF = 10 ** 9



def dfs(cur, a, b, c):

	if cur == N:

		return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF

	ret0 = dfs(cur + 1, a, b, c)

	ret1 = dfs(cur + 1, a + l[cur], b, c) + 10

	ret2 = dfs(cur + 1, a, b + l[cur], c) + 10

	ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10

	return min(ret0, ret1, ret2, ret3)



print((dfs(0, 0, 0, 0)))
n, A, B, C = (int(i) for i in input().split())
l = [int(eval(input())) for i in range(n)]
a = []
b = []
c = []


def furiwake(x):
    global a
    global b
    global c
    a = []
    b = []
    c = []
    for i in range(1, n + 1):
        if dig4(x, i) == 0:
            a.append(l[i - 1])
        if dig4(x, i) == 1:
            b.append(l[i - 1])
        if dig4(x, i) == 2:
            c.append(l[i - 1])


def dig4(n, k):
    return (n % (4**k)) // (4 ** (k - 1))


def cost():
    costa = 10 * (len(a) - 1) + abs(sum(a) - A)
    costb = 10 * (len(b) - 1) + abs(sum(b) - B)
    costc = 10 * (len(c) - 1) + abs(sum(c) - C)
    return costa + costb + costc


ans = 1000000000
for i in range(1, 4**8):
    furiwake(i)
    if len(a) * len(b) * len(c):
        ans = min(ans, cost())
print(ans)

N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for i in range(N)]
INF = 10**9


def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


print((dfs(0, 0, 0, 0)))

-n, A, B, C = (int(i) for i in input().split()) -l = [int(eval(input())) for i in range(n)] -a = [] -b = [] -c = [] +N, A, B, C = list(map(int, input().split())) +l = [int(eval(input())) for i in range(N)] +INF = 10**9 -def furiwake(x): -    global a -    global b -    global c -    a = [] -    b = [] -    c = [] -    for i in range(1, n + 1): -        if dig4(x, i) == 0: -            a.append(l[i - 1]) -        if dig4(x, i) == 1: -            b.append(l[i - 1]) -        if dig4(x, i) == 2: -            c.append(l[i - 1]) +def dfs(cur, a, b, c): +    if cur == N: +        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF +    ret0 = dfs(cur + 1, a, b, c) +    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10 +    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10 +    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10 +    return min(ret0, ret1, ret2, ret3) -def dig4(n, k): -    return (n % (4**k)) // (4 ** (k - 1)) - - -def cost(): -    costa = 10 * (len(a) - 1) + abs(sum(a) - A) -    costb = 10 * (len(b) - 1) + abs(sum(b) - B) -    costc = 10 * (len(c) - 1) + abs(sum(c) - C) -    return costa + costb + costc - - -ans = 1000000000 -for i in range(1, 4**8): -    furiwake(i) -    if len(a) * len(b) * len(c): -        ans = min(ans, cost()) -print(ans) +print((dfs(0, 0, 0, 0)))