import scala.io.StdIn.{readInt,readLine}

object Main {
  def scan(h:Array[Long],diff:Long,i:Int):Long = {
    if(i==1)
      scan(h,h(1)-h(0),i+1)
    else {
      if(h(i)-h(i-1) != diff) {
        if(i==h.length-1) h(i)
        else if(h(i+1)-h(i) == h(i)-h(i-1)) h(i-2)
        else if(i < h.length-2 && h(i+2)-h(i+1) == h(i+1)-h(i)) h(i-1)
        else h(i)
      } else
        scan(h,diff,i+1)
    }
  }

  def main(args:Array[String]):Unit = {
    println {
      Iterator.continually(readInt).takeWhile(_!=0).map { n=>
        val h = readLine.split(" ").map(_.toLong)
        scan(h,0,1)
      }.mkString("\n")
    }
  }
}