Language: C++

using System;
using System.Collections.Generic;
using System.ComponentModel.Design;

class Program
{
	public static int Main()
	{
		Scanner cin = new Scanner();
		while (true)
		{
			int n = cin.nextInt();
			if (n == 0)
			{
				break;
			}
			long[] h = new long[n + 1];
			for (int i = 0; i < n + 1; i++)
			{
				h[i] = cin.nextInt();
			}
			int[] cnt = new int[n + 1];
			bool writed = false;
			for (int i = 1; i < n; i++)
			{
				if (h[i] - h[i - 1] != h[i + 1] - h[i])
				{
					cnt[i - 1]++;
					cnt[i]++;
					cnt[i + 1]++;
					if (cnt[i - 1] == 3)
					{
						Console.WriteLine(h[i - 1]);
						writed = true;
						break;
					}
				}
			}
			if (!writed)
			{
				if (cnt[0] == 1)
				{
					Console.WriteLine(cnt[1] == 2 ? h[1] : h[0]);
				}
				else
				{
					Console.WriteLine(cnt[n - 1] == 2 ? h[n - 1] : h[n]);
				}
			}
		}
		return 0;
	}
}

class Scanner {
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner() {
		s = new string[0];
		i = 0;
	}

	public string next() {
		if (i < s.Length) return s[i++];
		do {
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		} while ((s.Length == 1 && s[0] == "") || s.Length == 0);
		i = 0;
		return s[i++];
	}

	public int nextInt() {
		return int.Parse(next());
	}

	public long nextLong() {
		return long.Parse(next());
	}

	public double nextDouble() {
		return double.Parse(next());
	}

}

Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.ComponentModel.Design;
      |       ^~~~~~
a.cc:7:15: error: expected ':' before 'static'
    7 |         public static int Main()
      |               ^~~~~~~
      |               :
a.cc:53:2: error: expected ';' after class definition
   53 | }
      |  ^
      |  ;
a.cc: In static member function 'static int Program::Main()':
a.cc:9:17: error: 'Scanner' was not declared in this scope
    9 |                 Scanner cin = new Scanner();
      |                 ^~~~~~~
a.cc:12:33: error: 'cin' was not declared in this scope
   12 |                         int n = cin.nextInt();
      |                                 ^~~
a.cc:17:29: error: structured binding declaration cannot have type 'long int'
   17 |                         long[] h = new long[n + 1];
      |                             ^~
a.cc:17:29: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:17:29: error: empty structured binding declaration
a.cc:17:32: error: expected initializer before 'h'
   17 |                         long[] h = new long[n + 1];
      |                                ^
a.cc:20:33: error: 'h' was not declared in this scope
   20 |                                 h[i] = cin.nextInt();
      |                                 ^
a.cc:22:28: error: structured binding declaration cannot have type 'int'
   22 |                         int[] cnt = new int[n + 1];
      |                            ^~
a.cc:22:28: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:22:28: error: empty structured binding declaration
a.cc:22:31: error: expected initializer before 'cnt'
   22 |                         int[] cnt = new int[n + 1];
      |                               ^~~
a.cc:26:37: error: 'h' was not declared in this scope
   26 |                                 if (h[i] - h[i - 1] != h[i + 1] - h[i])
      |                                     ^
a.cc:28:41: error: 'cnt' was not declared in this scope; did you mean 'int'?
   28 |                                         cnt[i - 1]++;
      |                                         ^~~
      |                                         int
a.cc:33:49: error: 'Console' was not declared in this scope
   33 |                                                 Console.WriteLine(h[i - 1]);
      |                                                 ^~~~~~~
a.cc:41:37: error: 'cnt' was not declared in this scope; did you mean 'int'?
   41 |                                 if (cnt[0] == 1)
      |                                     ^~~
      |                                     int
a.cc:43:41: error: 'Console' was not declared in this scope
   43 |                                         Console.WriteLine(cnt[1] == 2 ? h[1] : h[0]);
      |                                         ^~~~~~~
a.cc:43:73: error: 'h' was not declared in this scope
   43 |                                         Console.WriteLine(cnt[1] == 2 ? h[1] : h[0]);
      |                                                                         ^
a.cc:47:41: error: 'Console' was not declared in this scope
   47 |                                         Console.WriteLine(cnt[n - 1] == 2 ? h[n - 1] : h[n]);
      |                                         ^~~~~~~
a.cc:47:77: error: 'h' was not declared in this scope
   47 |                                         Console.WriteLine(cnt[n - 1] == 2 ? h[n - 1] : h[n]);
      |                                                                             ^
a.cc: At global scope:
a.cc:56:9: error: 'string' does not name a type
   56 |         string[] s;
      |         ^~~~~~
a.cc:59:13: error: expected unqualified-id before '[' token
   59 |         char[] cs = new char[] { ' ' };
      |             ^
a.cc:61:15: error: expected ':' before 'Scanner'
   61 |         public Scanner() {
      |               ^~~~~~~~
      |               :
a.cc:66:15: error: expected ':' before 'string'
   66 |         public string next() {
      |               ^~~~~~~
      |               :
a.cc:66:16: error: 'string' does not name a type
   66 |         public string next() {
      |                ^~~~~~
a.cc:75:15: error: expected ':' before 'int'
   75 |         public int nextInt() {
      |               ^~~~
      |               :
a.cc:79:15: error: expected ':' before 'long'
   79 |         public long nextLong() {
      |               ^~~~~
      |               :
a.cc:83:15: error: expected ':' before 'double'
   83 |         public double nextDouble() {
      |               ^~~~~~~
      |               :
a.cc:87:2: error: expected ';' after class definition
   87 | }
      |  ^
      |  ;
a.cc: In constructor 'Scanner::Scanner()':
a.cc:62:17: error: 's' was not declared in this scope
   62 |                 s = new string[0];
      |                 ^
a.cc:62:25: error: 'string' does not name a type
   62 |                 s = new string[0];
      |                         ^~~~~~
a.cc: In member function 'int Scanner::nextInt()':
a.cc:76:24: error: expected primary-expression before 'int'
   76 |                 return int.Parse(next());
      |                        ^~~
a.cc:76:24: error: expected ';' before 'int'
a.cc:76:27: error: expected unqualified-id before '.' token
   76 |                 return int.Parse(next());
      |                           ^
a.cc: In member function 'long int Scanner::nextLong()':
a.cc:80:24: error: expected primary-expression before 'long'
   80 |                 return long.Parse(next());
      |                        ^~~~
a.cc:80:24: error: expected ';' before 'long'
a.cc:80:28: error: expected unqualified-id before '.' token
   80 |                 return long.Parse(next());
      |                            ^
a.cc: In member function 'double Scanner::nextDouble()':
a.cc:84:24: error: expected primary-expression before 'double'
   84 |                 return double.Parse(next());
      |                        ^~~~~~
a.cc:84:24: error: expected ';' before 'double'
a.cc:84:30: error: expected unqualified-id before '.' token
   84 |                 return double.Parse(next());
      |                              ^