gets;f=gets.split.map &:to_i puts f.all?{|k|a=k;f.index{k==a=f[a-1]}%2<1}?:Yes:'No'