#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  bool f = 1;
  int aa[105];
  for (int i = 1; i <= n; i++) scanf("%d", &aa[i]);
  int ff = aa[2] - aa[1];
  for (int i = 3, a, b; i <= n; i++) {
    if (aa[i] - aa[i - 1] != ff) {
      f = 0;
      break;
    }
  }
  f ? printf("%d\n", aa[n] + ff) : printf("%d\n", aa[n]);
  return 0;
}
