; 全ての参加者の得点表を作り記録していく
; プロの得点が最大値であれば YES その他は NO を出力する
(defun main ()
  (let* ((n (read))
         (scores (loop repeat n collect (read)))
         (score-table (make-array 101 :initial-element 0)))
    (loop for score in scores
          for solver = (read)
          do (incf (aref score-table solver) score))
    (princ (if (= (aref score-table 0)
                  (reduce #'max score-table))
               "YES"
               "NO"))
    (terpri)))
(main)