n, m = gets.split.map(&:to_i) ranks = gets.split.map(&:to_i) classes = [] ranks.each do |i| if i % m == 0 s = i / m - 1 a = m else s = i / m a = i % m end classes << if s.even? a else m + 1 - a end end puts classes[0] == classes[1] ? 'YES' : 'NO'