#https://atcoder.jp/contests/abc119/tasks/abc119_c

#2019-02-24

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

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





ans = []

# 00 なら使わない、 01 ならAをつくる、10 ならBをつくる、11ならCをつくる　

for i in range(1 << 2*N):

    A_hon = 0

    B_hon = 0

    C_hon = 0

    A_zai = 0

    B_zai = 0

    C_zai = 0

    for k in range(N):

        if i & (1<<(2*k)) and i & (1<< (2*k)+1):

            C_hon += 1

            C_zai += l[k]

        elif i & (1<<(2*k)+1):

            B_hon += 1

            B_zai += l[k]

        elif i & (1<<(2*k)):

            A_hon += 1

            A_zai += l[k]

    if A_hon * B_hon * C_hon >0:

       ans += [10*(A_hon - 1)+ abs(A_zai - A)+10*(B_hon - 1)+ abs(B_zai - B)+ 10*(C_hon - 1)+ abs(C_zai - C)]

print((min(ans)))
import itertools

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

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

li =  itertools.product(list(range(4)), repeat=N)



ans = float("inf")

for i in li:

  cnt = [0]*3

  length = [0]*3

  for k in range(N):

    if i[k] == 3: 

      continue

    cnt[i[k]] += 1

    length[i[k]] += l[k]

  if min(cnt) > 0:

    cost = sum([abs(length[i]-A[i]) +10*cnt[i] for i in range(3)]) -30

    ans = min(ans, cost)

  

print(ans)
# https://atcoder.jp/contests/abc119/tasks/abc119_c
# 2019-02-24
N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(N)]
ans = []
# 00 なら使わない、 01 ならAをつくる、10 ならBをつくる、11ならCをつくる
for i in range(1 << 2 * N):
    A_hon = 0
    B_hon = 0
    C_hon = 0
    A_zai = 0
    B_zai = 0
    C_zai = 0
    for k in range(N):
        if i & (1 << (2 * k)) and i & (1 << (2 * k) + 1):
            C_hon += 1
            C_zai += l[k]
        elif i & (1 << (2 * k) + 1):
            B_hon += 1
            B_zai += l[k]
        elif i & (1 << (2 * k)):
            A_hon += 1
            A_zai += l[k]
    if A_hon * B_hon * C_hon > 0:
        ans += [
            10 * (A_hon - 1)
            + abs(A_zai - A)
            + 10 * (B_hon - 1)
            + abs(B_zai - B)
            + 10 * (C_hon - 1)
            + abs(C_zai - C)
        ]
print((min(ans)))

import itertools

N, *A = list(map(int, input().split()))
l = [int(eval(input())) for i in range(N)]
li = itertools.product(list(range(4)), repeat=N)
ans = float("inf")
for i in li:
    cnt = [0] * 3
    length = [0] * 3
    for k in range(N):
        if i[k] == 3:
            continue
        cnt[i[k]] += 1
        length[i[k]] += l[k]
    if min(cnt) > 0:
        cost = sum([abs(length[i] - A[i]) + 10 * cnt[i] for i in range(3)]) - 30
        ans = min(ans, cost)
print(ans)

-# https://atcoder.jp/contests/abc119/tasks/abc119_c -# 2019-02-24 -N, A, B, C = list(map(int, input().split())) -l = [int(eval(input())) for _ in range(N)] -ans = [] -# 00 なら使わない、 01 ならAをつくる、10 ならBをつくる、11ならCをつくる -for i in range(1 << 2 * N): -    A_hon = 0 -    B_hon = 0 -    C_hon = 0 -    A_zai = 0 -    B_zai = 0 -    C_zai = 0 +import itertools + +N, *A = list(map(int, input().split())) +l = [int(eval(input())) for i in range(N)] +li = itertools.product(list(range(4)), repeat=N) +ans = float("inf") +for i in li: +    cnt = [0] * 3 +    length = [0] * 3 -        if i & (1 << (2 * k)) and i & (1 << (2 * k) + 1): -            C_hon += 1 -            C_zai += l[k] -        elif i & (1 << (2 * k) + 1): -            B_hon += 1 -            B_zai += l[k] -        elif i & (1 << (2 * k)): -            A_hon += 1 -            A_zai += l[k] -    if A_hon * B_hon * C_hon > 0: -        ans += [ -            10 * (A_hon - 1) -            + abs(A_zai - A) -            + 10 * (B_hon - 1) -            + abs(B_zai - B) -            + 10 * (C_hon - 1) -            + abs(C_zai - C) -        ] -print((min(ans))) +        if i[k] == 3: +            continue +        cnt[i[k]] += 1 +        length[i[k]] += l[k] +    if min(cnt) > 0: +        cost = sum([abs(length[i] - A[i]) + 10 * cnt[i] for i in range(3)]) - 30 +        ans = min(ans, cost) +print(ans)