#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 50;
const int inf = 0x3f3f3f3f;
int a[150];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  bool flag = 1;
  if (n == 1)
    cout << a[0] << endl;
  else {
    int cnt = a[1] - a[0];
    for (int i = 2; i < n; ++i) {
      if (a[i] - a[i - 1] != cnt) {
        flag = 0;
        break;
      }
    }
    if (flag)
      cout << a[n - 1] + cnt << endl;
    else
      cout << a[n - 1] << endl;
  }
  return 0;
}
