#include <bits/stdc++.h>

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

bool ans(vector<int> &h){
	int d = h[1] - h[0];
//	for(auto e : h)cerr << e << " "; cerr << endl;
	for(int i = 1; i < h.size(); i++){
		if(h[i] - h[i-1] != d)return false;
	}
	return true;
}

signed main(){
	while(true){
		int n; cin >> n;
		if(n == 0 )break;
		vector<int> h(n+1);
		for(auto &e : h)cin >> e;
		for(int i = 0; i < n+1; i++){
			vector<int> tmp;
			for(int j = 0; j < n+1; j++){
				if(i == j)continue;
				tmp.push_back(h[j]);
			}
			if(ans(tmp)){
				cout << h[i] << endl;
				break;
			}
		}
	}

	return 0;
}


