#include <bits/stdc++.h>
using namespace std;
int a[10123];
const double eps = 0.000001;
int main() {
  int n = 0;
  while (cin >> a[n]) {
    n++;
  }
  if (n == 1) {
    cout << 42;
    return 0;
  }
  int diff = a[1] - a[0];
  double q = (double)a[1] / a[0];
  bool bad1 = false, bad2 = false;
  for (int i = 2; i < n; i++) {
    if (a[i] - a[i - 1] != diff) {
      bad1 = true;
      break;
    }
  }
  if (!bad1) {
    cout << a[n - 1] + diff;
    return 0;
  }
  for (int i = 2; i < n; i++) {
    if (abs((double)a[i] / a[i - 1] - q) > eps) {
      bad2 = true;
      break;
    }
  }
  if (!bad2 && (int)((int)(a[n - 1] * q) / q) == a[n - 1]) {
    cout << a[n - 1] * q;
    return 0;
  }
  cout << 42;
  return 0;
}
