from itertools import permutations, combinations





def solve(string):

    n, a, b, c, *l = list(map(int, string.split()))

    ans = 3000

    for _l in permutations(l):

        for i, j, k in combinations(list(range(1, len(l) + 1)), 3):

            tmp = 10 * (i - 1) + abs(a - sum(_l[:i]))

            if tmp > ans:

                continue

            tmp += 10 * (j - i - 1) + abs(b - sum(_l[i:j]))

            if tmp > ans:

                continue

            tmp += 10 * (k - j - 1) + abs(c - sum(_l[j:k]))

            if tmp < ans:

                ans = tmp

    return str(ans)





if __name__ == '__main__':

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

    print((solve('{} {} {} {}\n'.format(n, a, b, c) + '\n'.join([eval(input()) for _ in range(n)]))))

from itertools import product





def solve(string):

    n, a, b, c, *l = list(map(int, string.split()))

    ans = 3000

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

        if not ({0, 1, 2} <= set(p)):

            continue

        sums = [0, 0, 0, 0]

        for _p, _l in zip(p, l):

            sums[_p] += _l

        mp12 = sum(abs(_s - _abc) for _s, _abc in zip(sums[:3], [a, b, c]))

        mp3 = sum(1 for _p in p if _p < 3) - 3

        ans = min(ans, mp12 + mp3 * 10)

    return str(ans)





if __name__ == '__main__':

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

    print((solve('{} {} {} {}\n'.format(n, a, b, c) + '\n'.join([eval(input()) for _ in range(n)]))))

from itertools import permutations, combinations


def solve(string):
    n, a, b, c, *l = list(map(int, string.split()))
    ans = 3000
    for _l in permutations(l):
        for i, j, k in combinations(list(range(1, len(l) + 1)), 3):
            tmp = 10 * (i - 1) + abs(a - sum(_l[:i]))
            if tmp > ans:
                continue
            tmp += 10 * (j - i - 1) + abs(b - sum(_l[i:j]))
            if tmp > ans:
                continue
            tmp += 10 * (k - j - 1) + abs(c - sum(_l[j:k]))
            if tmp < ans:
                ans = tmp
    return str(ans)


if __name__ == "__main__":
    n, a, b, c = list(map(int, input().split()))
    print(
        (
            solve(
                "{} {} {} {}\n".format(n, a, b, c)
                + "\n".join([eval(input()) for _ in range(n)])
            )
        )
    )

from itertools import product


def solve(string):
    n, a, b, c, *l = list(map(int, string.split()))
    ans = 3000
    for p in product(list(range(4)), repeat=n):
        if not ({0, 1, 2} <= set(p)):
            continue
        sums = [0, 0, 0, 0]
        for _p, _l in zip(p, l):
            sums[_p] += _l
        mp12 = sum(abs(_s - _abc) for _s, _abc in zip(sums[:3], [a, b, c]))
        mp3 = sum(1 for _p in p if _p < 3) - 3
        ans = min(ans, mp12 + mp3 * 10)
    return str(ans)


if __name__ == "__main__":
    n, a, b, c = list(map(int, input().split()))
    print(
        (
            solve(
                "{} {} {} {}\n".format(n, a, b, c)
                + "\n".join([eval(input()) for _ in range(n)])
            )
        )
    )

-from itertools import permutations, combinations +from itertools import product -    for _l in permutations(l): -        for i, j, k in combinations(list(range(1, len(l) + 1)), 3): -            tmp = 10 * (i - 1) + abs(a - sum(_l[:i])) -            if tmp > ans: -                continue -            tmp += 10 * (j - i - 1) + abs(b - sum(_l[i:j])) -            if tmp > ans: -                continue -            tmp += 10 * (k - j - 1) + abs(c - sum(_l[j:k])) -            if tmp < ans: -                ans = tmp +    for p in product(list(range(4)), repeat=n): +        if not ({0, 1, 2} <= set(p)): +            continue +        sums = [0, 0, 0, 0] +        for _p, _l in zip(p, l): +            sums[_p] += _l +        mp12 = sum(abs(_s - _abc) for _s, _abc in zip(sums[:3], [a, b, c])) +        mp3 = sum(1 for _p in p if _p < 3) - 3 +        ans = min(ans, mp12 + mp3 * 10)