def slove():

    import sys, itertools

    input = sys.stdin.readline

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

    l = [int(input().rstrip('\n')) for _ in range(n)]

    ls = [0, 1, 2, 3]

    m_cost = 10 ** 10



    for it in itertools.product(ls, repeat=n):

        if 1 in it and 2 in it and 3 in it:

            lst = [0] * 4

            cost = 0

            for i, v in enumerate(it):

                lst[v] += l[i]

                if v == 1 or v == 2 or v == 3:

                    cost += 10

            cost -= 30

            cost += (abs(lst[1] - a) + abs(lst[2] - b) + abs(lst[3] - c))

            m_cost = min(m_cost, cost)

    print(m_cost)





if __name__ == '__main__':

    slove()

def slove():

    import sys

    import itertools

    input = sys.stdin.readline

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

    l = [int(input().rstrip('\n')) for _ in range(n)]

    mt = 10 ** 10

    for v in itertools.product([i for i in range(4)], repeat=n):

        nl = [[] for _ in range(4)]

        for i, vv in enumerate(v):

            nl[vv].append(l[i])

        if len(nl[1]) != 0 and len(nl[2]) != 0 and len(nl[3]) != 0:

            t = 0

            t += ((len(nl[1]) - 1) * 10 + abs(a - sum(nl[1])))

            t += ((len(nl[2]) - 1) * 10 + abs(b - sum(nl[2])))

            t += ((len(nl[3]) - 1) * 10 + abs(c - sum(nl[3])))

            mt = min(t, mt)

    print(mt)





if __name__ == '__main__':

    slove()

def slove():
    import sys, itertools

    input = sys.stdin.readline
    n, a, b, c = list(map(int, input().rstrip("\n").split()))
    l = [int(input().rstrip("\n")) for _ in range(n)]
    ls = [0, 1, 2, 3]
    m_cost = 10**10
    for it in itertools.product(ls, repeat=n):
        if 1 in it and 2 in it and 3 in it:
            lst = [0] * 4
            cost = 0
            for i, v in enumerate(it):
                lst[v] += l[i]
                if v == 1 or v == 2 or v == 3:
                    cost += 10
            cost -= 30
            cost += abs(lst[1] - a) + abs(lst[2] - b) + abs(lst[3] - c)
            m_cost = min(m_cost, cost)
    print(m_cost)


if __name__ == "__main__":
    slove()

def slove():
    import sys
    import itertools

    input = sys.stdin.readline
    n, a, b, c = list(map(int, input().rstrip("\n").split()))
    l = [int(input().rstrip("\n")) for _ in range(n)]
    mt = 10**10
    for v in itertools.product([i for i in range(4)], repeat=n):
        nl = [[] for _ in range(4)]
        for i, vv in enumerate(v):
            nl[vv].append(l[i])
        if len(nl[1]) != 0 and len(nl[2]) != 0 and len(nl[3]) != 0:
            t = 0
            t += (len(nl[1]) - 1) * 10 + abs(a - sum(nl[1]))
            t += (len(nl[2]) - 1) * 10 + abs(b - sum(nl[2]))
            t += (len(nl[3]) - 1) * 10 + abs(c - sum(nl[3]))
            mt = min(t, mt)
    print(mt)


if __name__ == "__main__":
    slove()

-    import sys, itertools +    import sys +    import itertools -    ls = [0, 1, 2, 3] -    m_cost = 10**10 -    for it in itertools.product(ls, repeat=n): -        if 1 in it and 2 in it and 3 in it: -            lst = [0] * 4 -            cost = 0 -            for i, v in enumerate(it): -                lst[v] += l[i] -                if v == 1 or v == 2 or v == 3: -                    cost += 10 -            cost -= 30 -            cost += abs(lst[1] - a) + abs(lst[2] - b) + abs(lst[3] - c) -            m_cost = min(m_cost, cost) -    print(m_cost) +    mt = 10**10 +    for v in itertools.product([i for i in range(4)], repeat=n): +        nl = [[] for _ in range(4)] +        for i, vv in enumerate(v): +            nl[vv].append(l[i]) +        if len(nl[1]) != 0 and len(nl[2]) != 0 and len(nl[3]) != 0: +            t = 0 +            t += (len(nl[1]) - 1) * 10 + abs(a - sum(nl[1])) +            t += (len(nl[2]) - 1) * 10 + abs(b - sum(nl[2])) +            t += (len(nl[3]) - 1) * 10 + abs(c - sum(nl[3])) +            mt = min(t, mt) +    print(mt)