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

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

INF=1e9



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

  if i==n:

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

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

    else:

      return INF

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

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

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

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

  return min(ret0,ret1,ret2,ret3)

 

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

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

inf=10**18

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

  if cur==N:

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

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

    else:

      return inf

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

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

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

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

  return min(res0,res1,res2,res3)

print((dfs(0,0,0,0)))
(
    n,
    A,
    B,
    C,
) = list(map(int, input().split()))
l = [int(eval(input())) for i in range(n)]
INF = 1e9


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


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

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


def dfs(cur, a, b, c):
    if cur == N:
        if min(a, b, c) > 0:
            return abs(A - a) + abs(B - b) + abs(C - c) - 30
        else:
            return inf
    res0 = dfs(cur + 1, a, b, c)
    res1 = dfs(cur + 1, a + l[cur], b, c) + 10
    res2 = dfs(cur + 1, a, b + l[cur], c) + 10
    res3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(res0, res1, res2, res3)


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

-( -    n, -    A, -    B, -    C, -) = list(map(int, input().split())) -l = [int(eval(input())) for i in range(n)] -INF = 1e9 +N, A, B, C = list(map(int, input().split())) +l = [int(eval(input())) for _ in range(N)] +inf = 10**18 -def dfs(i, a, b, c): -    if i == n: +def dfs(cur, a, b, c): +    if cur == N: -            return INF -    ret0 = dfs(i + 1, a, b, c) -    ret1 = dfs(i + 1, a + l[i], b, c) + 10 -    ret2 = dfs(i + 1, a, b + l[i], c) + 10 -    ret3 = dfs(i + 1, a, b, c + l[i]) + 10 -    return min(ret0, ret1, ret2, ret3) +            return inf +    res0 = dfs(cur + 1, a, b, c) +    res1 = dfs(cur + 1, a + l[cur], b, c) + 10 +    res2 = dfs(cur + 1, a, b + l[cur], c) + 10 +    res3 = dfs(cur + 1, a, b, c + l[cur]) + 10 +    return min(res0, res1, res2, res3)