n = gets.to_i a = [] yes = 0 n.times do |i| a[i] = gets.to_s if i >= 1 and a[i] != a[i-1] yes += 1 elsif i >= 1 and a[i] == a[i-1] puts "NO" break end end if yes == n - 1 puts "YES" end