import sys
readline = sys.stdin.readline

def base_10_to_n(i, n):
    if i//n:
        return base_10_to_n(i//n, n) + str(i % n)
    return str(i % n)

def main():
    N, A, B, C = map(int, readline().rstrip().split())
    l = [int(readline()) for _ in range(N)]
    ans = 10**6
    for i in range(4**N):
        b = base_10_to_n(i, 4).zfill(N)
        if '1' not in b or '2' not in b or '3' not in b:
            continue
        ai = [l[j] for j, e in enumerate(b) if e == '1']
        bi = [l[j] for j, e in enumerate(b) if e == '2']
        ci = [l[j] for j, e in enumerate(b) if e == '3']
        cost = (len(ai)+len(bi)+len(ci)-3) * 10 + abs(A-sum(ai)) + abs(B-sum(bi)) + abs(C-sum(ci))
        ans = min(ans, cost)

    print(ans)

if __name__ == '__main__':
    main() import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline def base_10_to_n(i, n):
    if i//n:
        return base_10_to_n(i//n, n) + str(i % n)
    return str(i % n) base_10_to_n if i//n:
        return base_10_to_n(i//n, n) + str(i % n)
     i//n i n return base_10_to_n(i//n, n) + str(i % n) base_10_to_n(i//n, n) + str(i % n) base_10_to_n(i//n, n) base_10_to_n i//n i n n str(i % n) str i % n i n return str(i % n) str(i % n) str i % n i n i i n n def main():
    N, A, B, C = map(int, readline().rstrip().split())
    l = [int(readline()) for _ in range(N)]
    ans = 10**6
    for i in range(4**N):
        b = base_10_to_n(i, 4).zfill(N)
        if '1' not in b or '2' not in b or '3' not in b:
            continue
        ai = [l[j] for j, e in enumerate(b) if e == '1']
        bi = [l[j] for j, e in enumerate(b) if e == '2']
        ci = [l[j] for j, e in enumerate(b) if e == '3']
        cost = (len(ai)+len(bi)+len(ci)-3) * 10 + abs(A-sum(ai)) + abs(B-sum(bi)) + abs(C-sum(ci))
        ans = min(ans, cost)

    print(ans) main N, A, B, C = map(int, readline().rstrip().split()) N map(int, readline().rstrip().split()) map int readline().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () readline rstrip split A B C int(readline()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(readline()) int readline() readline l = [int(readline()) for _ in range(N)] l [int(readline()) for _ in range(N)] ans = 10**6 ans 10**6 10 6 for i in range(4**N):
        b = base_10_to_n(i, 4).zfill(N)
        if '1' not in b or '2' not in b or '3' not in b:
            continue
        ai = [l[j] for j, e in enumerate(b) if e == '1']
        bi = [l[j] for j, e in enumerate(b) if e == '2']
        ci = [l[j] for j, e in enumerate(b) if e == '3']
        cost = (len(ai)+len(bi)+len(ci)-3) * 10 + abs(A-sum(ai)) + abs(B-sum(bi)) + abs(C-sum(ci))
        ans = min(ans, cost)

     i range(4**N) range 4**N 4 N b = base_10_to_n(i, 4).zfill(N) b base_10_to_n(i, 4).zfill(N) (i, 4).zfill (i, 4) base_10_to_n i 4 zfill N if '1' not in b or '2' not in b or '3' not in b:
            continue
         '1' not in b or '2' not in b or '3' not in b '1' not in b or '2' not in b '1' not in b '1' b '2' not in b '2' b '3' not in b '3' b continue l[j] for j, e in enumerate(b) if e == '1' for j, e in enumerate(b) if e == '1' j e enumerate(b) enumerate b e == '1' e '1' if e == '1' l[j] l j ai = [l[j] for j, e in enumerate(b) if e == '1'] ai [l[j] for j, e in enumerate(b) if e == '1'] l[j] for j, e in enumerate(b) if e == '2' for j, e in enumerate(b) if e == '2' j e enumerate(b) enumerate b e == '2' e '2' if e == '2' l[j] l j bi = [l[j] for j, e in enumerate(b) if e == '2'] bi [l[j] for j, e in enumerate(b) if e == '2'] l[j] for j, e in enumerate(b) if e == '3' for j, e in enumerate(b) if e == '3' j e enumerate(b) enumerate b e == '3' e '3' if e == '3' l[j] l j ci = [l[j] for j, e in enumerate(b) if e == '3'] ci [l[j] for j, e in enumerate(b) if e == '3'] cost = (len(ai)+len(bi)+len(ci)-3) * 10 + abs(A-sum(ai)) + abs(B-sum(bi)) + abs(C-sum(ci)) cost (len(ai)+len(bi)+len(ci)-3) * 10 + abs(A-sum(ai)) + abs(B-sum(bi)) + abs(C-sum(ci)) (len(ai)+len(bi)+len(ci)-3) * 10 + abs(A-sum(ai)) + abs(B-sum(bi)) (len(ai)+len(bi)+len(ci)-3) * 10 + abs(A-sum(ai)) (len(ai)+len(bi)+len(ci)-3) * 10 len(ai)+len(bi)+len(ci)-3 len(ai)+len(bi)+len(ci) len(ai)+len(bi) len(ai) len ai len(bi) len bi len(ci) len ci 3 10 abs(A-sum(ai)) abs A-sum(ai) A sum(ai) sum ai abs(B-sum(bi)) abs B-sum(bi) B sum(bi) sum bi abs(C-sum(ci)) abs C-sum(ci) C sum(ci) sum ci 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 readline = sys.stdin.readline sys.stdin.readline readline def base_10_to_n(i, n):
    if i//n:
        return base_10_to_n(i//n, n) + str(i % n)
    return str(i % n) def base_10_to_n(i, n):
    if i//n:
        return base_10_to_n(i//n, n) + str(i % n)
    return str(i % n) base_10_to_n def main():
    N, A, B, C = map(int, readline().rstrip().split())
    l = [int(readline()) for _ in range(N)]
    ans = 10**6
    for i in range(4**N):
        b = base_10_to_n(i, 4).zfill(N)
        if '1' not in b or '2' not in b or '3' not in b:
            continue
        ai = [l[j] for j, e in enumerate(b) if e == '1']
        bi = [l[j] for j, e in enumerate(b) if e == '2']
        ci = [l[j] for j, e in enumerate(b) if e == '3']
        cost = (len(ai)+len(bi)+len(ci)-3) * 10 + abs(A-sum(ai)) + abs(B-sum(bi)) + abs(C-sum(ci))
        ans = min(ans, cost)

    print(ans) def main():
    N, A, B, C = map(int, readline().rstrip().split())
    l = [int(readline()) for _ in range(N)]
    ans = 10**6
    for i in range(4**N):
        b = base_10_to_n(i, 4).zfill(N)
        if '1' not in b or '2' not in b or '3' not in b:
            continue
        ai = [l[j] for j, e in enumerate(b) if e == '1']
        bi = [l[j] for j, e in enumerate(b) if e == '2']
        ci = [l[j] for j, e in enumerate(b) if e == '3']
        cost = (len(ai)+len(bi)+len(ci)-3) * 10 + abs(A-sum(ai)) + abs(B-sum(bi)) + abs(C-sum(ci))
        ans = min(ans, cost)

    print(ans) main
import sys
readline = sys.stdin.readline

def base_10_to_n(i, n):
    if i//n:
        return base_10_to_n(i//n, n) + str(i % n)
    return str(i % n)

def main():
    N, A, B, C = map(int, readline().rstrip().split())
    l = [int(readline()) for _ in range(N)]
    ans = 10**6
    for i in range(4**N):
        b = base_10_to_n(i, 4).zfill(N)
        if '1' not in b or '2' not in b or '3' not in b:
            continue
        ai = [l[j] for j, e in enumerate(b) if e == '1']
        bi = [l[j] for j, e in enumerate(b) if e == '2']
        ci = [l[j] for j, e in enumerate(b) if e == '3']
        cost = (len(ai)+len(bi)+len(ci)-3) * 10 + abs(A-sum(ai)) + abs(B-sum(bi)) + abs(C-sum(ci))
        ans = min(ans, cost)

    print(ans)

if __name__ == '__main__':
    main()