import std.conv;
import std.stdio;
import std.array;
import std.range;
import std.string;
import std.algorithm;

void main()
{
	while(true)
	{
		auto n = readln.chomp.to!int;
		if(n == 0) break;
		
		auto hs = readln.split.map!(a => a.to!int()).array;

		foreach(i; 0..(n+1)) {
			if(isCommonDiff(hs[0..i] ~ hs[(i+1)..(n+1)])) {
				writeln(hs[i]);
				break;
			}			
		}
	}
}

bool isCommonDiff(int[] ary)
{
	auto n = ary[1] - ary[0];
	
	foreach(i; 2..ary.length) {
		if(ary[i] - ary[i-1] != n) {
			return false;
		}
	}

	return true;
}