#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 + 5;
int a[MAXN];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int d = a[2] - a[1];
  bool flag = true;
  for (int i = 3; i <= n; i++) {
    if (a[i] - a[i - 1] != d) {
      flag = false;
    }
  }
  if (flag)
    cout << a[n] + d << endl;
  else
    cout << a[n] << endl;
  return 0;
}
