#!/usr/bin/env python3
from itertools import product
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, A: int, B: int, C: int, l: "List[int]"):
    m = None
    for p in product(range(4), repeat=N):
        a = {i for i in range(N) if p[i] == 0}
        b = {i for i in range(N) if p[i] == 1}
        c = {i for i in range(N) if p[i] == 2}
        if not a or not b or not c:
            continue
        md = (
            abs(sum(l[ai] for ai in a) - A) + 10 * (len(a) - 1) +
            abs(sum(l[bi] for bi in b) - B) + 10 * (len(b) - 1) +
            abs(sum(l[ci] for ci in c) - C) + 10 * (len(c) - 1)
        )
        if m is None or m > md:
            m = md

    print(m)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    l = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, C, l)


if __name__ == '__main__':
    main() from itertools import product import sys sys try:
    from typing import List
except ImportError:
    pass except ImportError:
    pass from typing import List def solve(N: int, A: int, B: int, C: int, l: "List[int]"):
    m = None
    for p in product(range(4), repeat=N):
        a = {i for i in range(N) if p[i] == 0}
        b = {i for i in range(N) if p[i] == 1}
        c = {i for i in range(N) if p[i] == 2}
        if not a or not b or not c:
            continue
        md = (
            abs(sum(l[ai] for ai in a) - A) + 10 * (len(a) - 1) +
            abs(sum(l[bi] for bi in b) - B) + 10 * (len(b) - 1) +
            abs(sum(l[ci] for ci in c) - C) + 10 * (len(c) - 1)
        )
        if m is None or m > md:
            m = md

    print(m) solve m = None m None for p in product(range(4), repeat=N):
        a = {i for i in range(N) if p[i] == 0}
        b = {i for i in range(N) if p[i] == 1}
        c = {i for i in range(N) if p[i] == 2}
        if not a or not b or not c:
            continue
        md = (
            abs(sum(l[ai] for ai in a) - A) + 10 * (len(a) - 1) +
            abs(sum(l[bi] for bi in b) - B) + 10 * (len(b) - 1) +
            abs(sum(l[ci] for ci in c) - C) + 10 * (len(c) - 1)
        )
        if m is None or m > md:
            m = md

     p product(range(4), repeat=N) product range(4) range 4 repeat=N repeat N i for i in range(N) if p[i] == 0 for i in range(N) if p[i] == 0 i range(N) range N p[i] == 0 p[i] p i 0 if p[i] == 0 i a = {i for i in range(N) if p[i] == 0} a i for i in range(N) if p[i] == 1 for i in range(N) if p[i] == 1 i range(N) range N p[i] == 1 p[i] p i 1 if p[i] == 1 i b = {i for i in range(N) if p[i] == 1} b i for i in range(N) if p[i] == 2 for i in range(N) if p[i] == 2 i range(N) range N p[i] == 2 p[i] p i 2 if p[i] == 2 i c = {i for i in range(N) if p[i] == 2} c if not a or not b or not c:
            continue
         not a or not b or not c not a or not b not a a not b b not c c continue md = (
            abs(sum(l[ai] for ai in a) - A) + 10 * (len(a) - 1) +
            abs(sum(l[bi] for bi in b) - B) + 10 * (len(b) - 1) +
            abs(sum(l[ci] for ci in c) - C) + 10 * (len(c) - 1)
        ) md abs(sum(l[ai] for ai in a) - A) + 10 * (len(a) - 1) +
            abs(sum(l[bi] for bi in b) - B) + 10 * (len(b) - 1) +
            abs(sum(l[ci] for ci in c) - C) + 10 * (len(c) - 1) abs(sum(l[ai] for ai in a) - A) + 10 * (len(a) - 1) +
            abs(sum(l[bi] for bi in b) - B) + 10 * (len(b) - 1) +
            abs(sum(l[ci] for ci in c) - C) abs(sum(l[ai] for ai in a) - A) + 10 * (len(a) - 1) +
            abs(sum(l[bi] for bi in b) - B) + 10 * (len(b) - 1) abs(sum(l[ai] for ai in a) - A) + 10 * (len(a) - 1) +
            abs(sum(l[bi] for bi in b) - B) abs(sum(l[ai] for ai in a) - A) + 10 * (len(a) - 1) abs(sum(l[ai] for ai in a) - A) abs sum(l[ai] for ai in a) - A sum(l[ai] for ai in a) sum l[ai] l ai A 10 * (len(a) - 1) 10 len(a) - 1 len(a) len a 1 abs(sum(l[bi] for bi in b) - B) abs sum(l[bi] for bi in b) - B sum(l[bi] for bi in b) sum l[bi] l bi B 10 * (len(b) - 1) 10 len(b) - 1 len(b) len b 1 abs(sum(l[ci] for ci in c) - C) abs sum(l[ci] for ci in c) - C sum(l[ci] for ci in c) sum l[ci] l ci C 10 * (len(c) - 1) 10 len(c) - 1 len(c) len c 1 if m is None or m > md:
            m = md

     m is None or m > md m is None m None m > md m md m = md m md print(m) print m N: int N A: int A B: int B C: int C l: "List[int]" l def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    l = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, C, l) main def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
     iterate_tokens for line in sys.stdin:
            for word in line.split():
                yield word
     line sys.stdin sys stdin for word in line.split():
                yield word
     word line.split() line.split line split yield word word tokens = iterate_tokens() tokens iterate_tokens() iterate_tokens N = int(next(tokens)) N int(next(tokens)) int next(tokens) next tokens A = int(next(tokens)) A int(next(tokens)) int next(tokens) next tokens B = int(next(tokens)) B int(next(tokens)) int next(tokens) next tokens C = int(next(tokens)) C int(next(tokens)) int next(tokens) next tokens int(next(tokens)) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(next(tokens)) int next(tokens) next tokens l = [int(next(tokens)) for _ in range(N)] l [int(next(tokens)) for _ in range(N)] solve(N, A, B, C, l) solve N A B C l if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    l = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, C, l) def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    l = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, C, l) main def solve(N: int, A: int, B: int, C: int, l: "List[int]"):
    m = None
    for p in product(range(4), repeat=N):
        a = {i for i in range(N) if p[i] == 0}
        b = {i for i in range(N) if p[i] == 1}
        c = {i for i in range(N) if p[i] == 2}
        if not a or not b or not c:
            continue
        md = (
            abs(sum(l[ai] for ai in a) - A) + 10 * (len(a) - 1) +
            abs(sum(l[bi] for bi in b) - B) + 10 * (len(b) - 1) +
            abs(sum(l[ci] for ci in c) - C) + 10 * (len(c) - 1)
        )
        if m is None or m > md:
            m = md

    print(m) def solve(N: int, A: int, B: int, C: int, l: "List[int]"):
    m = None
    for p in product(range(4), repeat=N):
        a = {i for i in range(N) if p[i] == 0}
        b = {i for i in range(N) if p[i] == 1}
        c = {i for i in range(N) if p[i] == 2}
        if not a or not b or not c:
            continue
        md = (
            abs(sum(l[ai] for ai in a) - A) + 10 * (len(a) - 1) +
            abs(sum(l[bi] for bi in b) - B) + 10 * (len(b) - 1) +
            abs(sum(l[ci] for ci in c) - C) + 10 * (len(c) - 1)
        )
        if m is None or m > md:
            m = md

    print(m) solve
#!/usr/bin/env python3
from itertools import product
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, A: int, B: int, C: int, l: "List[int]"):
    m = None
    for p in product(range(4), repeat=N):
        a = {i for i in range(N) if p[i] == 0}
        b = {i for i in range(N) if p[i] == 1}
        c = {i for i in range(N) if p[i] == 2}
        if not a or not b or not c:
            continue
        md = (
            abs(sum(l[ai] for ai in a) - A) + 10 * (len(a) - 1) +
            abs(sum(l[bi] for bi in b) - B) + 10 * (len(b) - 1) +
            abs(sum(l[ci] for ci in c) - C) + 10 * (len(c) - 1)
        )
        if m is None or m > md:
            m = md

    print(m)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    l = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, C, l)


if __name__ == '__main__':
    main()
