#include <bits/stdc++.h>
using namespace std;
int n;
int t[110];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> t[i];
  int ap = t[2] - t[1];
  bool ok = true;
  for (int i = 3; i <= n; i++)
    if (t[i] - t[i - 1] != ap) {
      ok = false;
      break;
    }
  if (ok)
    cout << t[n] + ap;
  else
    cout << t[n];
  return 0;
}
