import sys

sys.setrecursionlimit(10**7)



n, a, b, c = list(map(int, input().split()))

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



mp = float('inf')

def f(i, anum, alen, bnum, blen, cnum, clen):

    global mp

    if i == n:

        if alen * blen * clen == 0:

            return

        mp = min(mp, abs(anum-a)+10*(alen-1) + abs(bnum-b)+10*(blen-1) + abs(cnum-c)+10*(clen-1))

    else:

        f(i+1, anum+l[i], alen+1, bnum, blen, cnum, clen)

        f(i+1, anum, alen, bnum+l[i], blen+1, cnum, clen)

        f(i+1, anum, alen, bnum, blen, cnum+l[i], clen+1)

        f(i+1, anum, alen, bnum, blen, cnum, clen)



f(0, 0, 0, 0, 0, 0, 0)





print(mp)
import sys

sys.setrecursionlimit(10**7)



n, a, b, c = list(map(int, input().split()))

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



mp = [float('inf')]

def f(i, anum, alen, bnum, blen, cnum, clen):

    if i == n:

        if alen * blen * clen == 0:

            return

        mp[0] = min(mp[0], abs(anum-a)+10*(alen-1) + abs(bnum-b)+10*(blen-1) + abs(cnum-c)+10*(clen-1))

    else:

        f(i+1, anum+l[i], alen+1, bnum, blen, cnum, clen)

        f(i+1, anum, alen, bnum+l[i], blen+1, cnum, clen)

        f(i+1, anum, alen, bnum, blen, cnum+l[i], clen+1)

        f(i+1, anum, alen, bnum, blen, cnum, clen)



f(0, 0, 0, 0, 0, 0, 0)





print((mp[0]))
import sys

sys.setrecursionlimit(10**7)
n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
mp = float("inf")


def f(i, anum, alen, bnum, blen, cnum, clen):
    global mp
    if i == n:
        if alen * blen * clen == 0:
            return
        mp = min(
            mp,
            abs(anum - a)
            + 10 * (alen - 1)
            + abs(bnum - b)
            + 10 * (blen - 1)
            + abs(cnum - c)
            + 10 * (clen - 1),
        )
    else:
        f(i + 1, anum + l[i], alen + 1, bnum, blen, cnum, clen)
        f(i + 1, anum, alen, bnum + l[i], blen + 1, cnum, clen)
        f(i + 1, anum, alen, bnum, blen, cnum + l[i], clen + 1)
        f(i + 1, anum, alen, bnum, blen, cnum, clen)


f(0, 0, 0, 0, 0, 0, 0)
print(mp)

import sys

sys.setrecursionlimit(10**7)
n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
mp = [float("inf")]


def f(i, anum, alen, bnum, blen, cnum, clen):
    if i == n:
        if alen * blen * clen == 0:
            return
        mp[0] = min(
            mp[0],
            abs(anum - a)
            + 10 * (alen - 1)
            + abs(bnum - b)
            + 10 * (blen - 1)
            + abs(cnum - c)
            + 10 * (clen - 1),
        )
    else:
        f(i + 1, anum + l[i], alen + 1, bnum, blen, cnum, clen)
        f(i + 1, anum, alen, bnum + l[i], blen + 1, cnum, clen)
        f(i + 1, anum, alen, bnum, blen, cnum + l[i], clen + 1)
        f(i + 1, anum, alen, bnum, blen, cnum, clen)


f(0, 0, 0, 0, 0, 0, 0)
print((mp[0]))

-mp = float("inf") +mp = [float("inf")] -    global mp -        mp = min( -            mp, +        mp[0] = min( +            mp[0], -print(mp) +print((mp[0]))