#include <iostream>
using namespace std;
 
int main()
{
  while (true)
  {
    int n;
    cin >> n;
    if (!n)
    {
      break;
    }
    int h[101];
    for (int i=0; i<=n; i++)
    {
      cin >> h[i];
    }
 
    int def[4] = { h[1]-h[0],
                   h[2]-h[1],
                   h[3]-h[2],
                   h[4]-h[3] };
 
    if (def[0]==def[1] && def[1]==def[2] && def[2]==def[3])
    {
      for (int i=5; i<=n; i++)
      {
    if (h[i]-h[i-1] != def[0])
    {
      cout << h[i] << endl;
      break;
    }
      }
    }
    else if (def[0] == def[3])
    {
      cout << h[2] << endl;
    }
    else if (def[1] == def[2])
    {
      if (def[2] == def[3])
      {
    cout << h[0] << endl;
      }
      else
      {
    cout << h[4] << endl;
      }
    }
    else
    {
      if ((def[0]+def[1])*2 == def[2]+def[3])
      {
    cout << h[1] << endl;
      }
      else
      {
    cout << h[3] << endl;
      }
    }
  }
 
  return 0;
}