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

vector<int> getvec(vector<int> v, int m){
    vector<int> buf;
    int n = v.size();
    for(int i=0;i<n;i++){
        if(i != m)buf.push_back(v[i]);
    }
    return buf;
}

bool isok(vector<int> v){
    int d = v[1] - v[0];
    int s = v.size();
    for(int i=1;i<s-1;i++){
        if(v[i+1]-v[i] != d)
            return false;
    }
    return true;
}

int solve(int n,vector<int> v){
    for(int i=0;i<n;i++){
        if(isok(getvec(v,i))){
            return v[i];
        }
    }
}



int main(){
    while(true){
        vector<int> v;
        int n;
        cin >> n;
        if(n == 0)break;
        n++;
        for(int i=0;i<n;i++){
            int tmp;
            cin >> tmp;
            v.push_back(tmp);
        }
        cout << solve(n,v) << endl;
    }
    return 0;
}