N=gets.to_i A=[0]+gets.split.map(&:to_i) puts (1..N).count{|i| t=[i] j=A[i] until j==i t<< j j=A[j] end t.size%2<1 }?:YES:"NO"