#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a, b;
  cin >> a >> b;
  int dif = b - a;
  bool ar = true;
  for (int i = 0; i < n - 2; i++) {
    int aux;
    cin >> aux;
    if (aux - b != dif) {
      ar = false;
    }
    b = aux;
  }
  if (ar) {
    cout << a + dif * (n);
  } else {
    cout << b;
  }
}
