from itertools import permutations





def solve(string):

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

    ans = 3000



    for _l in permutations(l):

        for i in range(1, len(l) - 1):

            for j in range(i + 1, len(l)):

                for k in range(j + 1, len(l) + 1):

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

                        b - sum(_l[i:j])) + 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 permutations





def solve(string):

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

    ans = 3000



    for _l in permutations(l):

        for i in range(1, len(l) - 1):

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

            if tmp_a >= ans:

                continue

            for j in range(i + 1, len(l)):

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

                if tmp_a + tmp_b >= ans:

                    continue

                for k in range(j + 1, len(l) + 1):

                    tmp = tmp_a + tmp_b + 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 permutations


def solve(string):
    n, a, b, c, *l = list(map(int, string.split()))
    ans = 3000
    for _l in permutations(l):
        for i in range(1, len(l) - 1):
            for j in range(i + 1, len(l)):
                for k in range(j + 1, len(l) + 1):
                    tmp = (
                        10 * (i - 1)
                        + abs(a - sum(_l[:i]))
                        + 10 * (j - i - 1)
                        + abs(b - sum(_l[i:j]))
                        + 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 permutations


def solve(string):
    n, a, b, c, *l = list(map(int, string.split()))
    ans = 3000
    for _l in permutations(l):
        for i in range(1, len(l) - 1):
            tmp_a = 10 * (i - 1) + abs(a - sum(_l[:i]))
            if tmp_a >= ans:
                continue
            for j in range(i + 1, len(l)):
                tmp_b = 10 * (j - i - 1) + abs(b - sum(_l[i:j]))
                if tmp_a + tmp_b >= ans:
                    continue
                for k in range(j + 1, len(l) + 1):
                    tmp = tmp_a + tmp_b + 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)])
            )
        )
    )

+            tmp_a = 10 * (i - 1) + abs(a - sum(_l[:i])) +            if tmp_a >= ans: +                continue +                tmp_b = 10 * (j - i - 1) + abs(b - sum(_l[i:j])) +                if tmp_a + tmp_b >= ans: +                    continue -                    tmp = ( -                        10 * (i - 1) -                        + abs(a - sum(_l[:i])) -                        + 10 * (j - i - 1) -                        + abs(b - sum(_l[i:j])) -                        + 10 * (k - j - 1) -                        + abs(c - sum(_l[j:k])) -                    ) +                    tmp = tmp_a + tmp_b + 10 * (k - j - 1) + abs(c - sum(_l[j:k]))