N = int(eval(input()))

A = list(map(int, input().split()))

B = list(map(int, input().split()))



A_origin = A[:]



if sum(A) < sum(B):

    print((-1))

    exit()



diff = [[i, a - b] for i, a, b in zip(list(range(N)), A, B)]



order = sorted([[i, x] for i, x in diff if x > 0], key=lambda d: d[1])

C = []



charge = order.pop()

for i in range(N):

    while A[i] - B[i] < 0:

        if charge[1] > B[i] - A[i]:

            A[charge[0]] -= (B[i] - A[i])

            charge[1] -= (B[i] - A[i])

            A[i] = B[i]

        else:

            A[charge[0]] = B[charge[0]]

            A[i] += charge[1]

            charge = order.pop()



ans = 0

for a, ao in zip(A, A_origin):

    if a != ao:

        ans += 1



print(ans)

N = int(eval(input()))

A = list(map(int, input().split()))

B = list(map(int, input().split()))





# 各テストの余裕を小さい順に

margins = [[i, a - b] for i, (a, b) in enumerate(zip(A, B)) if (a - b) > 0]

margins.sort(key=lambda m: m[1])



# 調整済みA

X = A[:]



# 余裕が大きい方から使っていく

for i in range(N):

    while (A[i] < B[i]) and margins:

        cost = B[i] - A[i]

        mi, margin = margins[-1]



        if margin > cost:

            margins[-1][1] -= cost

            A[mi] -= cost

            A[i] += cost



        else:

            margins.pop()

            A[mi] -= margin

            A[i] += margin





ans = 0

for a, b, x in zip(A, B, X):

    if b - a > 0:

        print((-1))

        break



    if a != x:

        ans += 1

else:

    print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_origin = A[:]
if sum(A) < sum(B):
    print((-1))
    exit()
diff = [[i, a - b] for i, a, b in zip(list(range(N)), A, B)]
order = sorted([[i, x] for i, x in diff if x > 0], key=lambda d: d[1])
C = []
charge = order.pop()
for i in range(N):
    while A[i] - B[i] < 0:
        if charge[1] > B[i] - A[i]:
            A[charge[0]] -= B[i] - A[i]
            charge[1] -= B[i] - A[i]
            A[i] = B[i]
        else:
            A[charge[0]] = B[charge[0]]
            A[i] += charge[1]
            charge = order.pop()
ans = 0
for a, ao in zip(A, A_origin):
    if a != ao:
        ans += 1
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# 各テストの余裕を小さい順に
margins = [[i, a - b] for i, (a, b) in enumerate(zip(A, B)) if (a - b) > 0]
margins.sort(key=lambda m: m[1])
# 調整済みA
X = A[:]
# 余裕が大きい方から使っていく
for i in range(N):
    while (A[i] < B[i]) and margins:
        cost = B[i] - A[i]
        mi, margin = margins[-1]
        if margin > cost:
            margins[-1][1] -= cost
            A[mi] -= cost
            A[i] += cost
        else:
            margins.pop()
            A[mi] -= margin
            A[i] += margin
ans = 0
for a, b, x in zip(A, B, X):
    if b - a > 0:
        print((-1))
        break
    if a != x:
        ans += 1
else:
    print(ans)

-A_origin = A[:] -if sum(A) < sum(B): -    print((-1)) -    exit() -diff = [[i, a - b] for i, a, b in zip(list(range(N)), A, B)] -order = sorted([[i, x] for i, x in diff if x > 0], key=lambda d: d[1]) -C = [] -charge = order.pop() +# 各テストの余裕を小さい順に +margins = [[i, a - b] for i, (a, b) in enumerate(zip(A, B)) if (a - b) > 0] +margins.sort(key=lambda m: m[1]) +# 調整済みA +X = A[:] +# 余裕が大きい方から使っていく -    while A[i] - B[i] < 0: -        if charge[1] > B[i] - A[i]: -            A[charge[0]] -= B[i] - A[i] -            charge[1] -= B[i] - A[i] -            A[i] = B[i] +    while (A[i] < B[i]) and margins: +        cost = B[i] - A[i] +        mi, margin = margins[-1] +        if margin > cost: +            margins[-1][1] -= cost +            A[mi] -= cost +            A[i] += cost -            A[charge[0]] = B[charge[0]] -            A[i] += charge[1] -            charge = order.pop() +            margins.pop() +            A[mi] -= margin +            A[i] += margin -for a, ao in zip(A, A_origin): -    if a != ao: +for a, b, x in zip(A, B, X): +    if b - a > 0: +        print((-1)) +        break +    if a != x: -print(ans) +else: +    print(ans)