Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let b = Array.init n (fun _ -> Scanf.scanf " %d" (fun b -> b)) in
    let c = Array.init n (fun i -> a.(i) - b.(i)) in
    Array.sort compare c;
    let s = Array.fold_left (+) 0 c in

    Printf.printf "%d\n" @@
        if s < 0 then -1 else (
            let rec phase2 i j sum =
                if sum >= 0 then i + (n - 1 - j) else
                    phase2 i (j - 1) (sum + c.(j))
            in
            let rec phase1 i sum =
                if c.(i) < 0 then phase1 (i + 1) (sum + c.(i))
                             else phase2 i (n - 1) sum
            in
            phase1 0 0
        )
)