def main():
    from itertools import product

    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]

    ans = 3000
    for prod in product([0, 1, 2, 3], repeat=N):
        t = [[] for _ in range(3)]
        for i, x in enumerate(prod):
            if x == 3: continue
            t[x].append(i)
        if (not t[0]) or (not t[1]) or (not t[2]): continue

        cost = sum(len(t[i]) - 1 for i in range(3)) * 10
        a = sum(L[i] for i in t[0])
        b = sum(L[i] for i in t[1])
        c = sum(L[i] for i in t[2])
        cost += abs(A - a) + abs(B - b) + abs(C - c)
        if ans > cost:
            ans = cost

    print(ans)


if __name__ == '__main__':
    main() def main():
    from itertools import product

    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]

    ans = 3000
    for prod in product([0, 1, 2, 3], repeat=N):
        t = [[] for _ in range(3)]
        for i, x in enumerate(prod):
            if x == 3: continue
            t[x].append(i)
        if (not t[0]) or (not t[1]) or (not t[2]): continue

        cost = sum(len(t[i]) - 1 for i in range(3)) * 10
        a = sum(L[i] for i in t[0])
        b = sum(L[i] for i in t[1])
        c = sum(L[i] for i in t[2])
        cost += abs(A - a) + abs(B - b) + abs(C - c)
        if ans > cost:
            ans = cost

    print(ans) main from itertools import product 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 = 3000 ans 3000 for prod in product([0, 1, 2, 3], repeat=N):
        t = [[] for _ in range(3)]
        for i, x in enumerate(prod):
            if x == 3: continue
            t[x].append(i)
        if (not t[0]) or (not t[1]) or (not t[2]): continue

        cost = sum(len(t[i]) - 1 for i in range(3)) * 10
        a = sum(L[i] for i in t[0])
        b = sum(L[i] for i in t[1])
        c = sum(L[i] for i in t[2])
        cost += abs(A - a) + abs(B - b) + abs(C - c)
        if ans > cost:
            ans = cost

     prod product([0, 1, 2, 3], repeat=N) product [0, 1, 2, 3] 0 1 2 3 repeat=N repeat N [] for _ in range(3) for _ in range(3) _ range(3) range 3 for _ in range(3) [] t = [[] for _ in range(3)] t [[] for _ in range(3)] for i, x in enumerate(prod):
            if x == 3: continue
            t[x].append(i)
         i x enumerate(prod) enumerate prod if x == 3: continue
             x == 3 x 3 t[x].append(i) [x].append [x] t x append i if (not t[0]) or (not t[1]) or (not t[2]): continue

         (not t[0]) or (not t[1]) or (not t[2]) (not t[0]) or (not t[1]) not t[0] t[0] t 0 not t[1] t[1] t 1 not t[2] t[2] t 2 cost = sum(len(t[i]) - 1 for i in range(3)) * 10 cost sum(len(t[i]) - 1 for i in range(3)) * 10 sum(len(t[i]) - 1 for i in range(3)) sum len(t[i]) - 1 len(t[i]) len t[i] t i 1 10 a = sum(L[i] for i in t[0]) a sum(L[i] for i in t[0]) sum L[i] L i b = sum(L[i] for i in t[1]) b sum(L[i] for i in t[1]) sum L[i] L i c = sum(L[i] for i in t[2]) c sum(L[i] for i in t[2]) sum L[i] L i cost += abs(A - a) + abs(B - b) + abs(C - c) cost abs(A - a) + abs(B - b) + abs(C - c) abs(A - a) + abs(B - b) abs(A - a) abs A - a A a abs(B - b) abs B - b B b abs(C - c) abs C - c C c if ans > cost:
            ans = cost

     ans > cost ans cost ans = cost ans 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 = map(int, input().split())
    L = [int(input()) for _ in range(N)]

    ans = 3000
    for prod in product([0, 1, 2, 3], repeat=N):
        t = [[] for _ in range(3)]
        for i, x in enumerate(prod):
            if x == 3: continue
            t[x].append(i)
        if (not t[0]) or (not t[1]) or (not t[2]): continue

        cost = sum(len(t[i]) - 1 for i in range(3)) * 10
        a = sum(L[i] for i in t[0])
        b = sum(L[i] for i in t[1])
        c = sum(L[i] for i in t[2])
        cost += abs(A - a) + abs(B - b) + abs(C - c)
        if ans > cost:
            ans = cost

    print(ans) def main():
    from itertools import product

    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]

    ans = 3000
    for prod in product([0, 1, 2, 3], repeat=N):
        t = [[] for _ in range(3)]
        for i, x in enumerate(prod):
            if x == 3: continue
            t[x].append(i)
        if (not t[0]) or (not t[1]) or (not t[2]): continue

        cost = sum(len(t[i]) - 1 for i in range(3)) * 10
        a = sum(L[i] for i in t[0])
        b = sum(L[i] for i in t[1])
        c = sum(L[i] for i in t[2])
        cost += abs(A - a) + abs(B - b) + abs(C - c)
        if ans > cost:
            ans = cost

    print(ans) main
def main():
    from itertools import product

    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]

    ans = 3000
    for prod in product([0, 1, 2, 3], repeat=N):
        t = [[] for _ in range(3)]
        for i, x in enumerate(prod):
            if x == 3: continue
            t[x].append(i)
        if (not t[0]) or (not t[1]) or (not t[2]): continue

        cost = sum(len(t[i]) - 1 for i in range(3)) * 10
        a = sum(L[i] for i in t[0])
        b = sum(L[i] for i in t[1])
        c = sum(L[i] for i in t[2])
        cost += abs(A - a) + abs(B - b) + abs(C - c)
        if ans > cost:
            ans = cost

    print(ans)


if __name__ == '__main__':
    main()
