#include <bits/stdc++.h>
int main() {
  int n;
  scanf("%d", &n);
  int pre, now;
  int cha;
  scanf("%d", &pre);
  int flag = 1;
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d", &now);
    if (i == 1)
      cha = now - pre;
    else {
      if (cha != now - pre) flag = 0;
    }
    pre = now;
  }
  if (flag) {
    printf("%d\n", pre + cha);
  } else {
    printf("%d\n", pre);
  }
}
