#include<iostream>
#include<vector>
using namespace std;

int N;
int data[110];

void input(){
  for(int i = 0 ; i < N ; i++)cin >> data[i];
}

void solve(){
  input();
  for(int i = 0 ; i < N ; i++){
    vector<int>vec;
    for(int j = 0 ; j < N ; j++){
      if(j == i)continue;
      vec.push_back(data[j]);
    }

    int diff = vec[1] - vec[0];
    bool f = true;
    for(int j = 2 ; j < vec.size() ; j++){
      if(vec[j] - vec[j-1] != diff)f = false;
    }
    if(f){
      cout << data[i] << endl;
      return;
    }
  }
}

int main(){
  while(cin >> N,N){
    N++;
    solve();
  }
  return 0;
}