object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val d = Array.fill(n, 2)(sc.nextInt)

  val three = countZ(0, 0, d.map(z => z(0) == z(1)))
  if(three >= 3) {
    println("Yes")
  } else {
    println("No")
  }

  def countZ(z: Int, max: Int, dd: Array[Boolean]): Int ={
    val nz = if (dd.head) z + 1 else 0
    val nmax = Math.max(max, nz)
    return if(dd.length == 1) {
      nmax
    } else {
      countZ(nz, nmax, dd.tail)
    }
  }

}
