import std.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

bool f(int[] xs) {
    int d = xs[1] - xs[0];
    foreach (i; 0 .. xs.length - 1) {
        if (xs[i + 1] - xs[i] != d) return false;
    }
    return true;
}

void main() {
    int n;
    while (readf("%d\n", &n), n) {
        int[] xs = readln.chomp.split(" ").map!(to!int).array;
        foreach (i; 0 .. n + 1) {
            if (f(xs[0 .. i] ~ xs[i + 1 .. $])) {
                writeln(xs[i]);
                break;
            }
        }
    }
}