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

object Main {
  def isSequence(h:Array[Long]) = {
    val diff = h(1)-h(0)
    def scan(i:Int):Boolean = {
      if(i==h.length) true
      else if(h(i)-h(i-1) != diff) false
      else scan(i+1)
    }
    scan(1)
  }

  def main(args:Array[String]):Unit = {
    println {
      Iterator.continually(readInt).takeWhile(_!=0).map { n=>
        val h = readLine.split(" ").map(_.toLong).toBuffer
        def scan(i:Int):Long= {
          val a = h.toBuffer
          a.remove(i)
          if(i==h.length) -1
          else if(isSequence(a.toArray)) h(i)
          else scan(i+1)
        }
        scan(0)
      }.mkString("\n")
    }
  }
}