#include <bits/stdc++.h>
using namespace std;
long long arr[110];
int main() {
  int n;
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }
  if (sum == n * arr[0] + (n * (n - 1) * (arr[1] - arr[0])) / 2) {
    cout << arr[n - 1] + arr[1] - arr[0] << endl;
    return 0;
  }
  cout << arr[n - 1] << endl;
  return 0;
}
