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