#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))


int main(){
	int n,t,f;
	int h[101];
	for(;;){
		scanf("%d",&n);
		if(!n)break;
		n++;
		rep(i,n)scanf("%d",i+h);
		rep(i,n){
			f=1;
			t=h[1+(i<2)]-h[i==0];
			rep(j,n-2){
				if(t!=h[j+1+(j+1>=i)]-h[j+(j>=i)]){
					f=0;
					break;
				}
			}
			if(f){
				printf("%d\n",h[i]);
				break;
			}
		}
	}
	return 0;
}