#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, arr[102], n, dif = 0, temp = 0, count1 = 0, next = 0, flag = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  dif = arr[1] - arr[0];
  for (i = 0, j = 1; i < (n - 1); i++, j++) {
    if (dif != arr[j] - arr[i]) {
      flag = 1;
      break;
    }
  }
  if (flag == 0)
    cout << (arr[n - 1] + dif) << endl;
  else
    cout << arr[n - 1] << endl;
}
