#!/usr/bin/env python



from collections import deque

import itertools as it

import sys

import math



sys.setrecursionlimit(1000000)



INF = 10 ** 18



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

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



ans = 10 ** 12



for i in range(4 ** N):

  S = [0, 0, 0, 0]

  hoge = i

  cost = -30

  for j in range(N):

    S[hoge % 4] += l[j]

    if hoge % 4 < 3:

      cost += 10

    hoge /= 4

  if S[0] * S[1] * S[2] == 0:

    continue

  ans = min(ans, cost + abs(S[0] - A) + abs(S[1] - B) + abs(S[2] - C))



print(ans)
INF = 10 ** 18



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

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



def func(pos, a, b, c):return abs(a - A) + abs(b - B) + abs(c - C) - 30 + INF * max(0, 1 - a * b * c) if pos == N else min(func(pos + 1, a + ls[pos] * (i == 0), b + ls[pos] * (i == 1), c + ls[pos] * (i == 2)) + 10 * (i < 3) for i in range(4))

print((func(0, 0, 0, 0)))
#!/usr/bin/env python
from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)
INF = 10**18
N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for i in range(N)]
ans = 10**12
for i in range(4**N):
    S = [0, 0, 0, 0]
    hoge = i
    cost = -30
    for j in range(N):
        S[hoge % 4] += l[j]
        if hoge % 4 < 3:
            cost += 10
        hoge /= 4
    if S[0] * S[1] * S[2] == 0:
        continue
    ans = min(ans, cost + abs(S[0] - A) + abs(S[1] - B) + abs(S[2] - C))
print(ans)

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


def func(pos, a, b, c):
    return (
        abs(a - A) + abs(b - B) + abs(c - C) - 30 + INF * max(0, 1 - a * b * c)
        if pos == N
        else min(
            func(
                pos + 1,
                a + ls[pos] * (i == 0),
                b + ls[pos] * (i == 1),
                c + ls[pos] * (i == 2),
            )
            + 10 * (i < 3)
            for i in range(4)
        )
    )


print((func(0, 0, 0, 0)))

-#!/usr/bin/env python -from collections import deque -import itertools as it -import sys -import math - -sys.setrecursionlimit(1000000) -l = [int(eval(input())) for i in range(N)] -ans = 10**12 -for i in range(4**N): -    S = [0, 0, 0, 0] -    hoge = i -    cost = -30 -    for j in range(N): -        S[hoge % 4] += l[j] -        if hoge % 4 < 3: -            cost += 10 -        hoge /= 4 -    if S[0] * S[1] * S[2] == 0: -        continue -    ans = min(ans, cost + abs(S[0] - A) + abs(S[1] - B) + abs(S[2] - C)) -print(ans) +ls = [int(eval(input())) for i in range(N)] + + +def func(pos, a, b, c): +    return ( +        abs(a - A) + abs(b - B) + abs(c - C) - 30 + INF * max(0, 1 - a * b * c) +        if pos == N +        else min( +            func( +                pos + 1, +                a + ls[pos] * (i == 0), +                b + ls[pos] * (i == 1), +                c + ls[pos] * (i == 2), +            ) +            + 10 * (i < 3) +            for i in range(4) +        ) +    ) + + +print((func(0, 0, 0, 0)))