#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e7;
const int N = 2e5 + 5;
int n, a[103];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  int x, y;
  cin >> x >> y;
  int d = y - x;
  int ans = 0;
  a[1] = x;
  a[2] = y;
  for (int i = 3; i <= n; i++) {
    cin >> a[i];
    if (a[i] - a[i - 1] != d) {
      ans = 1;
    }
  }
  if (!ans)
    cout << a[n] + d;
  else
    cout << a[n];
  return 0;
}
