import strutils, sequtils, tables, math proc input: auto = stdin.readLine let N = input().parseInt a, b = input().split.map parseInt var left_points = a.sum competitors = initCountTable[int]() for i, b in b: let lost_points = a[i] if b != 0: left_points.dec lost_points if b notin competitors: competitors[b] = lost_points else: competitors[b].inc lost_points if left_points < competitors.largest.val: echo "NO" else: echo "YES"