def assert f unless f puts "Error!: Constraint Violation" exit end end n = gets.to_i a = gets.split.map(&:to_i) assert(2 <= n && n <= 500) a.each do |v| assert(1 <= v && v <= 100) end f = false (n-1).times do |i| f = true if a[i] == a[i+1] end (n-2).times do |i| f = true if a[i] == a[i+2] end puts f ? "Yes" : "No"