#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const int INF = 1000 * 1000 * 1000 + 7;
const long long LINF = INF * (long long)INF;
const int MAX = 100 + 47;
int A[MAX];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = (0); i < (n); i++) cin >> A[i];
  int d = A[1] - A[0];
  bool good = true;
  for (int i = (2); i < (n); i++) {
    if (A[i] - A[i - 1] != d) {
      good = false;
      break;
    }
  }
  if (good) {
    cout << A[n - 1] + d << endl;
    return 0;
  }
  cout << A[n - 1] << endl;
  return 0;
}
