fun readInt () = valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn) fun makeTable a_s b_s = let val table = Array.array (101, 0) fun makeTableAux () = ListPair.app (fn (a, b) => let val old = Array.sub (table, b) in Array.update (table, b, old + a) end) (a_s, b_s) in (makeTableAux (); table) end val () = let val n = readInt () val a_s = List.tabulate (n, fn _ => readInt ()) val b_s = List.tabulate (n, fn _ => readInt ()) val table = makeTable a_s b_s val (maxIndex, _) = Array.foldli (fn (i, score, (mi, ms)) => if ms < score then (i, score) else (mi, ms)) (0, Array.sub (table, 0)) table val ans = if maxIndex = 0 then "YES" else "NO" in print (ans ^ "\n") end