#include <bits/stdc++.h>
using namespace std;
int const inf = 0x3f3f3f3f;
int a[110];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int r = (a[n] - a[1]) / (n - 1);
  bool arit = true;
  for (int i = 2; i <= n; i++) {
    if (a[1] + (i - 1) * r != a[i]) arit = false;
  }
  if (!arit)
    printf("%d\n", a[n]);
  else
    printf("%d\n", a[1] + (n)*r);
  return 0;
}
