#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
vector<int> h;

int solve(int k){
  vector<int> a;
  rep(i,0,N){
    if(i == k) continue;
    a.push_back(h[i]);
  }

  int diff = a[1] - a[0];


  rep(i,0,N - 2){
    if(diff != a[i + 1] - a[i]) return false;
  }
  return true;
}

int main(){
  while(cin >> N,N){
    h.resize(N + 1);
    rep(i,0,N) cin >> h[i];

    rep(i,0,N){
      if(solve(i)){
        cout << h[i];
        break;
      }
    }

    cout << endl;
  }
}

