#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		vector<long long int> data(n+1);
		vector<long long int> data2(n);
		cin >> data[0];
		for (int i = 1; i <= n; i++) {
			cin >> data[i];
			data2[i-1] = data[i]-data[i-1];
		}
		if (data2[0] != data2[1]) {
			if (data2[0] == data2[n-1]) {
				cout << data[2] << endl;
			} else if(data2[1] == data2[n-1]) {
				cout << data[0] << endl;
			} else {
				cout << data[1] << endl;
			}
		} else {
			if (data2[0] != data2[2]) {
				if (data2[2] == data2[3]) {
					if (data2[0] == (data[4]-data[2])) {
						cout << data[3] << endl;
					} else {
						cout << data[1] << endl;
					}
				} else {
					cout << data[3] << endl;
				}
			} else {
				for (int i = 3; i < n; i++) {
					if (data2[0] != data2[i]) {
						cout << data[i+1] << endl;
						break;
					}
				}
			}
		}
	}
	return 0;
}