from itertools import product


def main():
    n, a, b, c = map(int, input().split())
    l = [int(input()) for _ in range(n)]
    ans = 10**4
    for p in product(range(4), repeat=n):
        abc = [[], [], []]
        for i, pi in enumerate(p):
            if pi > 0:
                abc[pi - 1].append(i)
        fl = False
        for i in abc:
            fl |= len(i) == 0
        if fl:
            continue
        cost = 0
        for i in range(3):
            cost += abs(sum(l[j] for j in abc[i]) - (a, b, c)[i]) + 10 * (len(abc[i]) - 1)
        ans = min(ans, cost)
    print(ans)


if __name__ == '__main__':
    main() from itertools import product def main():
    n, a, b, c = map(int, input().split())
    l = [int(input()) for _ in range(n)]
    ans = 10**4
    for p in product(range(4), repeat=n):
        abc = [[], [], []]
        for i, pi in enumerate(p):
            if pi > 0:
                abc[pi - 1].append(i)
        fl = False
        for i in abc:
            fl |= len(i) == 0
        if fl:
            continue
        cost = 0
        for i in range(3):
            cost += abs(sum(l[j] for j in abc[i]) - (a, b, c)[i]) + 10 * (len(abc[i]) - 1)
        ans = min(ans, cost)
    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)] ans = 10**4 ans 10**4 10 4 for p in product(range(4), repeat=n):
        abc = [[], [], []]
        for i, pi in enumerate(p):
            if pi > 0:
                abc[pi - 1].append(i)
        fl = False
        for i in abc:
            fl |= len(i) == 0
        if fl:
            continue
        cost = 0
        for i in range(3):
            cost += abs(sum(l[j] for j in abc[i]) - (a, b, c)[i]) + 10 * (len(abc[i]) - 1)
        ans = min(ans, cost)
     p product(range(4), repeat=n) product range(4) range 4 repeat=n repeat n abc = [[], [], []] abc [[], [], []] [] [] [] for i, pi in enumerate(p):
            if pi > 0:
                abc[pi - 1].append(i)
         i pi enumerate(p) enumerate p if pi > 0:
                abc[pi - 1].append(i)
         pi > 0 pi 0 abc[pi - 1].append(i) [pi - 1].append [pi - 1] abc pi - 1 pi 1 append i fl = False fl False for i in abc:
            fl |= len(i) == 0
         i abc fl |= len(i) == 0 fl len(i) == 0 len(i) len i 0 if fl:
            continue
         fl continue cost = 0 cost 0 for i in range(3):
            cost += abs(sum(l[j] for j in abc[i]) - (a, b, c)[i]) + 10 * (len(abc[i]) - 1)
         i range(3) range 3 cost += abs(sum(l[j] for j in abc[i]) - (a, b, c)[i]) + 10 * (len(abc[i]) - 1) cost abs(sum(l[j] for j in abc[i]) - (a, b, c)[i]) + 10 * (len(abc[i]) - 1) abs(sum(l[j] for j in abc[i]) - (a, b, c)[i]) abs sum(l[j] for j in abc[i]) - (a, b, c)[i] sum(l[j] for j in abc[i]) sum l[j] l j (a, b, c)[i] (a, b, c) a b c i 10 * (len(abc[i]) - 1) 10 len(abc[i]) - 1 len(abc[i]) len abc[i] abc i 1 ans = min(ans, cost) ans min(ans, cost) min ans cost 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)]
    ans = 10**4
    for p in product(range(4), repeat=n):
        abc = [[], [], []]
        for i, pi in enumerate(p):
            if pi > 0:
                abc[pi - 1].append(i)
        fl = False
        for i in abc:
            fl |= len(i) == 0
        if fl:
            continue
        cost = 0
        for i in range(3):
            cost += abs(sum(l[j] for j in abc[i]) - (a, b, c)[i]) + 10 * (len(abc[i]) - 1)
        ans = min(ans, cost)
    print(ans) def main():
    n, a, b, c = map(int, input().split())
    l = [int(input()) for _ in range(n)]
    ans = 10**4
    for p in product(range(4), repeat=n):
        abc = [[], [], []]
        for i, pi in enumerate(p):
            if pi > 0:
                abc[pi - 1].append(i)
        fl = False
        for i in abc:
            fl |= len(i) == 0
        if fl:
            continue
        cost = 0
        for i in range(3):
            cost += abs(sum(l[j] for j in abc[i]) - (a, b, c)[i]) + 10 * (len(abc[i]) - 1)
        ans = min(ans, cost)
    print(ans) main
from itertools import product


def main():
    n, a, b, c = map(int, input().split())
    l = [int(input()) for _ in range(n)]
    ans = 10**4
    for p in product(range(4), repeat=n):
        abc = [[], [], []]
        for i, pi in enumerate(p):
            if pi > 0:
                abc[pi - 1].append(i)
        fl = False
        for i in abc:
            fl |= len(i) == 0
        if fl:
            continue
        cost = 0
        for i in range(3):
            cost += abs(sum(l[j] for j in abc[i]) - (a, b, c)[i]) + 10 * (len(abc[i]) - 1)
        ans = min(ans, cost)
    print(ans)


if __name__ == '__main__':
    main()
