import sys
from itertools import product

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]
    P = product(range(4), repeat=N)

    # 0 -> not used
    # 1 -> A
    # 2 -> B
    # 3 -> C
    ans = INF
    for pattern in P:
        mp = 0
        a = 0
        b = 0
        c = 0
        for i, p in enumerate(pattern):
            if p == 0:
                continue
            elif p == 1:
                if a != 0:
                    mp += 10
                a += L[i]
            elif p == 2:
                if b != 0:
                    mp += 10
                b += L[i]
            else:
                if c != 0:
                    mp += 10
                c += L[i]

        if a == 0 or b == 0 or c == 0:
            continue

        mp += abs(A - a)
        mp += abs(B - b)
        mp += abs(C - c)

        if mp < ans:
            ans = mp

    print(ans)


if __name__ == "__main__":
    main() import sys sys from itertools import product sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 INF = float("inf") INF float("inf") float "inf" MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 def input():
    return sys.stdin.readline().strip() input return sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip def main():
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]
    P = product(range(4), repeat=N)

    # 0 -> not used
    # 1 -> A
    # 2 -> B
    # 3 -> C
    ans = INF
    for pattern in P:
        mp = 0
        a = 0
        b = 0
        c = 0
        for i, p in enumerate(pattern):
            if p == 0:
                continue
            elif p == 1:
                if a != 0:
                    mp += 10
                a += L[i]
            elif p == 2:
                if b != 0:
                    mp += 10
                b += L[i]
            else:
                if c != 0:
                    mp += 10
                c += L[i]

        if a == 0 or b == 0 or c == 0:
            continue

        mp += abs(A - a)
        mp += abs(B - b)
        mp += abs(C - c)

        if mp < ans:
            ans = mp

    print(ans) main N, A, B, C = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split A B C int(input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input L = [int(input()) for _ in range(N)] L [int(input()) for _ in range(N)] P = product(range(4), repeat=N) P product(range(4), repeat=N) product range(4) range 4 repeat=N repeat N ans = INF ans INF for pattern in P:
        mp = 0
        a = 0
        b = 0
        c = 0
        for i, p in enumerate(pattern):
            if p == 0:
                continue
            elif p == 1:
                if a != 0:
                    mp += 10
                a += L[i]
            elif p == 2:
                if b != 0:
                    mp += 10
                b += L[i]
            else:
                if c != 0:
                    mp += 10
                c += L[i]

        if a == 0 or b == 0 or c == 0:
            continue

        mp += abs(A - a)
        mp += abs(B - b)
        mp += abs(C - c)

        if mp < ans:
            ans = mp

     pattern P mp = 0 mp 0 a = 0 a 0 b = 0 b 0 c = 0 c 0 for i, p in enumerate(pattern):
            if p == 0:
                continue
            elif p == 1:
                if a != 0:
                    mp += 10
                a += L[i]
            elif p == 2:
                if b != 0:
                    mp += 10
                b += L[i]
            else:
                if c != 0:
                    mp += 10
                c += L[i]

         i p enumerate(pattern) enumerate pattern if p == 0:
                continue
            elif p == 1:
                if a != 0:
                    mp += 10
                a += L[i]
            elif p == 2:
                if b != 0:
                    mp += 10
                b += L[i]
            else:
                if c != 0:
                    mp += 10
                c += L[i]

         p == 0 p 0 continue elif p == 1:
                if a != 0:
                    mp += 10
                a += L[i]
             p == 1 p 1 if a != 0:
                    mp += 10
                 a != 0 a 0 mp += 10 mp 10 a += L[i] a L[i] L i elif p == 2:
                if b != 0:
                    mp += 10
                b += L[i]
             p == 2 p 2 if b != 0:
                    mp += 10
                 b != 0 b 0 mp += 10 mp 10 b += L[i] b L[i] L i if c != 0:
                    mp += 10
                 c != 0 c 0 mp += 10 mp 10 c += L[i] c L[i] L i if a == 0 or b == 0 or c == 0:
            continue

         a == 0 or b == 0 or c == 0 a == 0 or b == 0 a == 0 a 0 b == 0 b 0 c == 0 c 0 continue mp += abs(A - a) mp abs(A - a) abs A - a A a mp += abs(B - b) mp abs(B - b) abs B - b B b mp += abs(C - c) mp abs(C - c) abs C - c C c if mp < ans:
            ans = mp

     mp < ans mp ans ans = mp ans mp print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]
    P = product(range(4), repeat=N)

    # 0 -> not used
    # 1 -> A
    # 2 -> B
    # 3 -> C
    ans = INF
    for pattern in P:
        mp = 0
        a = 0
        b = 0
        c = 0
        for i, p in enumerate(pattern):
            if p == 0:
                continue
            elif p == 1:
                if a != 0:
                    mp += 10
                a += L[i]
            elif p == 2:
                if b != 0:
                    mp += 10
                b += L[i]
            else:
                if c != 0:
                    mp += 10
                c += L[i]

        if a == 0 or b == 0 or c == 0:
            continue

        mp += abs(A - a)
        mp += abs(B - b)
        mp += abs(C - c)

        if mp < ans:
            ans = mp

    print(ans) def main():
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]
    P = product(range(4), repeat=N)

    # 0 -> not used
    # 1 -> A
    # 2 -> B
    # 3 -> C
    ans = INF
    for pattern in P:
        mp = 0
        a = 0
        b = 0
        c = 0
        for i, p in enumerate(pattern):
            if p == 0:
                continue
            elif p == 1:
                if a != 0:
                    mp += 10
                a += L[i]
            elif p == 2:
                if b != 0:
                    mp += 10
                b += L[i]
            else:
                if c != 0:
                    mp += 10
                c += L[i]

        if a == 0 or b == 0 or c == 0:
            continue

        mp += abs(A - a)
        mp += abs(B - b)
        mp += abs(C - c)

        if mp < ans:
            ans = mp

    print(ans) main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD INF = float("inf") float("inf") INF def input():
    return sys.stdin.readline().strip() def input():
    return sys.stdin.readline().strip() input
import sys
from itertools import product

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]
    P = product(range(4), repeat=N)

    # 0 -> not used
    # 1 -> A
    # 2 -> B
    # 3 -> C
    ans = INF
    for pattern in P:
        mp = 0
        a = 0
        b = 0
        c = 0
        for i, p in enumerate(pattern):
            if p == 0:
                continue
            elif p == 1:
                if a != 0:
                    mp += 10
                a += L[i]
            elif p == 2:
                if b != 0:
                    mp += 10
                b += L[i]
            else:
                if c != 0:
                    mp += 10
                c += L[i]

        if a == 0 or b == 0 or c == 0:
            continue

        mp += abs(A - a)
        mp += abs(B - b)
        mp += abs(C - c)

        if mp < ans:
            ans = mp

    print(ans)


if __name__ == "__main__":
    main()
