def main():
    from itertools import product
    n, a, b, c, *l = map(int, open(0).read().split())
    k = ['A', 'B', 'C', 'D']
    cost = []
    for abcd in product(k, repeat=n):
        s, t, u = [], [], []
        for p, q in zip(abcd, l):
            if p == 'A':
                s.append(q)
            elif p == 'B':
                t.append(q)
            elif p == 'C':
                u.append(q)
        tmp = 0
        for p, q in zip([a, b, c], [s, t, u]):
            tmp += abs(p - sum(q)) + 10 * (len(q) - 1)

        if len(s) > 0 and len(t) > 0 and len(u) > 0:
            cost.append(tmp)

    ans = min(cost)
    print(ans)


if __name__ == '__main__':
    main() def main():
    from itertools import product
    n, a, b, c, *l = map(int, open(0).read().split())
    k = ['A', 'B', 'C', 'D']
    cost = []
    for abcd in product(k, repeat=n):
        s, t, u = [], [], []
        for p, q in zip(abcd, l):
            if p == 'A':
                s.append(q)
            elif p == 'B':
                t.append(q)
            elif p == 'C':
                u.append(q)
        tmp = 0
        for p, q in zip([a, b, c], [s, t, u]):
            tmp += abs(p - sum(q)) + 10 * (len(q) - 1)

        if len(s) > 0 and len(t) > 0 and len(u) > 0:
            cost.append(tmp)

    ans = min(cost)
    print(ans) main from itertools import product n, a, b, c, *l = map(int, open(0).read().split()) n map(int, open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split a b c *l l k = ['A', 'B', 'C', 'D'] k ['A', 'B', 'C', 'D'] 'A' 'B' 'C' 'D' cost = [] cost [] for abcd in product(k, repeat=n):
        s, t, u = [], [], []
        for p, q in zip(abcd, l):
            if p == 'A':
                s.append(q)
            elif p == 'B':
                t.append(q)
            elif p == 'C':
                u.append(q)
        tmp = 0
        for p, q in zip([a, b, c], [s, t, u]):
            tmp += abs(p - sum(q)) + 10 * (len(q) - 1)

        if len(s) > 0 and len(t) > 0 and len(u) > 0:
            cost.append(tmp)

     abcd product(k, repeat=n) product k repeat=n repeat n s, t, u = [], [], [] s [] t [] u [] for p, q in zip(abcd, l):
            if p == 'A':
                s.append(q)
            elif p == 'B':
                t.append(q)
            elif p == 'C':
                u.append(q)
         p q zip(abcd, l) zip abcd l if p == 'A':
                s.append(q)
            elif p == 'B':
                t.append(q)
            elif p == 'C':
                u.append(q)
         p == 'A' p 'A' s.append(q) s.append s append q elif p == 'B':
                t.append(q)
             p == 'B' p 'B' t.append(q) t.append t append q elif p == 'C':
                u.append(q)
         p == 'C' p 'C' u.append(q) u.append u append q tmp = 0 tmp 0 for p, q in zip([a, b, c], [s, t, u]):
            tmp += abs(p - sum(q)) + 10 * (len(q) - 1)

         p q zip([a, b, c], [s, t, u]) zip [a, b, c] a b c [s, t, u] s t u tmp += abs(p - sum(q)) + 10 * (len(q) - 1) tmp abs(p - sum(q)) + 10 * (len(q) - 1) abs(p - sum(q)) abs p - sum(q) p sum(q) sum q 10 * (len(q) - 1) 10 len(q) - 1 len(q) len q 1 if len(s) > 0 and len(t) > 0 and len(u) > 0:
            cost.append(tmp)

     len(s) > 0 and len(t) > 0 and len(u) > 0 len(s) > 0 and len(t) > 0 len(s) > 0 len(s) len s 0 len(t) > 0 len(t) len t 0 len(u) > 0 len(u) len u 0 cost.append(tmp) cost.append cost append tmp ans = min(cost) ans min(cost) min cost print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    from itertools import product
    n, a, b, c, *l = map(int, open(0).read().split())
    k = ['A', 'B', 'C', 'D']
    cost = []
    for abcd in product(k, repeat=n):
        s, t, u = [], [], []
        for p, q in zip(abcd, l):
            if p == 'A':
                s.append(q)
            elif p == 'B':
                t.append(q)
            elif p == 'C':
                u.append(q)
        tmp = 0
        for p, q in zip([a, b, c], [s, t, u]):
            tmp += abs(p - sum(q)) + 10 * (len(q) - 1)

        if len(s) > 0 and len(t) > 0 and len(u) > 0:
            cost.append(tmp)

    ans = min(cost)
    print(ans) def main():
    from itertools import product
    n, a, b, c, *l = map(int, open(0).read().split())
    k = ['A', 'B', 'C', 'D']
    cost = []
    for abcd in product(k, repeat=n):
        s, t, u = [], [], []
        for p, q in zip(abcd, l):
            if p == 'A':
                s.append(q)
            elif p == 'B':
                t.append(q)
            elif p == 'C':
                u.append(q)
        tmp = 0
        for p, q in zip([a, b, c], [s, t, u]):
            tmp += abs(p - sum(q)) + 10 * (len(q) - 1)

        if len(s) > 0 and len(t) > 0 and len(u) > 0:
            cost.append(tmp)

    ans = min(cost)
    print(ans) main
def main():
    from itertools import product
    n, a, b, c, *l = map(int, open(0).read().split())
    k = ['A', 'B', 'C', 'D']
    cost = []
    for abcd in product(k, repeat=n):
        s, t, u = [], [], []
        for p, q in zip(abcd, l):
            if p == 'A':
                s.append(q)
            elif p == 'B':
                t.append(q)
            elif p == 'C':
                u.append(q)
        tmp = 0
        for p, q in zip([a, b, c], [s, t, u]):
            tmp += abs(p - sum(q)) + 10 * (len(q) - 1)

        if len(s) > 0 and len(t) > 0 and len(u) > 0:
            cost.append(tmp)

    ans = min(cost)
    print(ans)


if __name__ == '__main__':
    main()
