#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 + 5;
const int inf = 1e9 + 7;
int n, m;
int num[MAXN];
map<int, int> q;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &num[i]);
  for (int i = 2; i <= n; ++i) {
    q[num[i] - num[i - 1]]++;
  }
  if (q.size() == 1)
    printf("%d\n", num[n] + num[2] - num[1]);
  else
    printf("%d\n", num[n]);
  return 0;
}
