from itertools import*

n,a,b,c,*l=list(map(int,open(0).read().split()))

d=[a,b,c]

ans=float("inf")

for i in product(list(range(4)),repeat=n):

    take=[[],[],[]]

    for k,j in enumerate(i):  #0を捨てる

        if j!=0:

            take[j-1].append(l[k])

    if all(take):

        take2=list(map(sum,take))

        #print(sum(abs(s-t)for s,t in zip(d,take2)),(sum(map(len,take))-3)*10)

        ans=min(ans,sum(abs(s-t)for s,t in zip(d,take2))+(sum(map(len,take))-3)*10)

print(ans)
from itertools import*

n,a,b,c,*l=list(map(int,open(0).read().split()))

ans=float("inf")

for i in product(list(range(4)),repeat=n): #3を捨てる

    take=[[],[],[]]

    for k,j in enumerate(i):

        if j==3:

            continue

        take[j].append(l[k])

    *tmp,=list(map(len,take))

    if all(tmp):

        x,y,z=list(map(sum,take))

        ans=min(ans, (sum(tmp)-3)*10 + abs(x-a) + abs(y-b) + abs(z-c) )

print(ans)
from itertools import *

n, a, b, c, *l = list(map(int, open(0).read().split()))
d = [a, b, c]
ans = float("inf")
for i in product(list(range(4)), repeat=n):
    take = [[], [], []]
    for k, j in enumerate(i):  # 0を捨てる
        if j != 0:
            take[j - 1].append(l[k])
    if all(take):
        take2 = list(map(sum, take))
        # print(sum(abs(s-t)for s,t in zip(d,take2)),(sum(map(len,take))-3)*10)
        ans = min(
            ans,
            sum(abs(s - t) for s, t in zip(d, take2)) + (sum(map(len, take)) - 3) * 10,
        )
print(ans)

from itertools import *

n, a, b, c, *l = list(map(int, open(0).read().split()))
ans = float("inf")
for i in product(list(range(4)), repeat=n):  # 3を捨てる
    take = [[], [], []]
    for k, j in enumerate(i):
        if j == 3:
            continue
        take[j].append(l[k])
    (*tmp,) = list(map(len, take))
    if all(tmp):
        x, y, z = list(map(sum, take))
        ans = min(ans, (sum(tmp) - 3) * 10 + abs(x - a) + abs(y - b) + abs(z - c))
print(ans)

-d = [a, b, c] -for i in product(list(range(4)), repeat=n): +for i in product(list(range(4)), repeat=n):  # 3を捨てる -    for k, j in enumerate(i):  # 0を捨てる -        if j != 0: -            take[j - 1].append(l[k]) -    if all(take): -        take2 = list(map(sum, take)) -        # print(sum(abs(s-t)for s,t in zip(d,take2)),(sum(map(len,take))-3)*10) -        ans = min( -            ans, -            sum(abs(s - t) for s, t in zip(d, take2)) + (sum(map(len, take)) - 3) * 10, -        ) +    for k, j in enumerate(i): +        if j == 3: +            continue +        take[j].append(l[k]) +    (*tmp,) = list(map(len, take)) +    if all(tmp): +        x, y, z = list(map(sum, take)) +        ans = min(ans, (sum(tmp) - 3) * 10 + abs(x - a) + abs(y - b) + abs(z - c))