n = gets.to_i a = gets.split.map(&:to_i) 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"