import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, A, B, C = in_nn()
    l = list(map(int, read().rstrip().split()))

    comb = list(itertools.product(range(4), repeat=N))
    ans = 10**9 + 7

    for c in comb:
        if (0 in c) and (1 in c) and (2 in c):
            t = [0] * 3
            m = [-10] * 3
            for i in range(N):
                if c[i] == 3:
                    continue
                t[c[i]] += l[i]
                m[c[i]] += 10

            m[0] += abs(t[0] - A)
            m[1] += abs(t[1] - B)
            m[2] += abs(t[2] - C)

            ans = min(ans, sum(m))

    print(ans)


if __name__ == '__main__':
    main() import sys sys import itertools itertools read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline in_n = lambda: int(readline()) in_n lambda: int(readline()) int(readline()) int readline() readline in_nn = lambda: map(int, readline().split()) in_nn lambda: map(int, readline().split()) map(int, readline().split()) map int readline().split() ().split () readline split in_s = lambda: readline().rstrip().decode('utf-8') in_s lambda: readline().rstrip().decode('utf-8') readline().rstrip().decode('utf-8') ().rstrip().decode ().rstrip() ().rstrip () readline rstrip decode 'utf-8' def main():
    N, A, B, C = in_nn()
    l = list(map(int, read().rstrip().split()))

    comb = list(itertools.product(range(4), repeat=N))
    ans = 10**9 + 7

    for c in comb:
        if (0 in c) and (1 in c) and (2 in c):
            t = [0] * 3
            m = [-10] * 3
            for i in range(N):
                if c[i] == 3:
                    continue
                t[c[i]] += l[i]
                m[c[i]] += 10

            m[0] += abs(t[0] - A)
            m[1] += abs(t[1] - B)
            m[2] += abs(t[2] - C)

            ans = min(ans, sum(m))

    print(ans) main N, A, B, C = in_nn() N in_nn() in_nn A B C l = list(map(int, read().rstrip().split())) l list(map(int, read().rstrip().split())) list map(int, read().rstrip().split()) map int read().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () read rstrip split comb = list(itertools.product(range(4), repeat=N)) comb list(itertools.product(range(4), repeat=N)) list itertools.product(range(4), repeat=N) itertools.product itertools product range(4) range 4 repeat=N repeat N ans = 10**9 + 7 ans 10**9 + 7 10**9 10 9 7 for c in comb:
        if (0 in c) and (1 in c) and (2 in c):
            t = [0] * 3
            m = [-10] * 3
            for i in range(N):
                if c[i] == 3:
                    continue
                t[c[i]] += l[i]
                m[c[i]] += 10

            m[0] += abs(t[0] - A)
            m[1] += abs(t[1] - B)
            m[2] += abs(t[2] - C)

            ans = min(ans, sum(m))

     c comb if (0 in c) and (1 in c) and (2 in c):
            t = [0] * 3
            m = [-10] * 3
            for i in range(N):
                if c[i] == 3:
                    continue
                t[c[i]] += l[i]
                m[c[i]] += 10

            m[0] += abs(t[0] - A)
            m[1] += abs(t[1] - B)
            m[2] += abs(t[2] - C)

            ans = min(ans, sum(m))

     (0 in c) and (1 in c) and (2 in c) (0 in c) and (1 in c) 0 in c 0 c 1 in c 1 c 2 in c 2 c t = [0] * 3 t [0] * 3 [0] 0 3 m = [-10] * 3 m [-10] * 3 [-10] -10 3 for i in range(N):
                if c[i] == 3:
                    continue
                t[c[i]] += l[i]
                m[c[i]] += 10

             i range(N) range N if c[i] == 3:
                    continue
                 c[i] == 3 c[i] c i 3 continue t[c[i]] += l[i] t[c[i]] t c[i] c i l[i] l i m[c[i]] += 10 m[c[i]] m c[i] c i 10 m[0] += abs(t[0] - A) m[0] m 0 abs(t[0] - A) abs t[0] - A t[0] t 0 A m[1] += abs(t[1] - B) m[1] m 1 abs(t[1] - B) abs t[1] - B t[1] t 1 B m[2] += abs(t[2] - C) m[2] m 2 abs(t[2] - C) abs t[2] - C t[2] t 2 C ans = min(ans, sum(m)) ans min(ans, sum(m)) min ans sum(m) sum m print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline read = sys.stdin.buffer.read sys.stdin.buffer.read read in_nn = lambda: map(int, readline().split()) lambda: map(int, readline().split()) in_nn in_n = lambda: int(readline()) lambda: int(readline()) in_n in_s = lambda: readline().rstrip().decode('utf-8') lambda: readline().rstrip().decode('utf-8') in_s def main():
    N, A, B, C = in_nn()
    l = list(map(int, read().rstrip().split()))

    comb = list(itertools.product(range(4), repeat=N))
    ans = 10**9 + 7

    for c in comb:
        if (0 in c) and (1 in c) and (2 in c):
            t = [0] * 3
            m = [-10] * 3
            for i in range(N):
                if c[i] == 3:
                    continue
                t[c[i]] += l[i]
                m[c[i]] += 10

            m[0] += abs(t[0] - A)
            m[1] += abs(t[1] - B)
            m[2] += abs(t[2] - C)

            ans = min(ans, sum(m))

    print(ans) def main():
    N, A, B, C = in_nn()
    l = list(map(int, read().rstrip().split()))

    comb = list(itertools.product(range(4), repeat=N))
    ans = 10**9 + 7

    for c in comb:
        if (0 in c) and (1 in c) and (2 in c):
            t = [0] * 3
            m = [-10] * 3
            for i in range(N):
                if c[i] == 3:
                    continue
                t[c[i]] += l[i]
                m[c[i]] += 10

            m[0] += abs(t[0] - A)
            m[1] += abs(t[1] - B)
            m[2] += abs(t[2] - C)

            ans = min(ans, sum(m))

    print(ans) main
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, A, B, C = in_nn()
    l = list(map(int, read().rstrip().split()))

    comb = list(itertools.product(range(4), repeat=N))
    ans = 10**9 + 7

    for c in comb:
        if (0 in c) and (1 in c) and (2 in c):
            t = [0] * 3
            m = [-10] * 3
            for i in range(N):
                if c[i] == 3:
                    continue
                t[c[i]] += l[i]
                m[c[i]] += 10

            m[0] += abs(t[0] - A)
            m[1] += abs(t[1] - B)
            m[2] += abs(t[2] - C)

            ans = min(ans, sum(m))

    print(ans)


if __name__ == '__main__':
    main()
