#include <bits/stdc++.h>
using namespace std;
long double a[1000005], n, cha, bi;
bool c = false, b = false;
int main() {
  int n = 1;
  while (cin >> a[n]) n++;
  cha = a[2] - a[1];
  bi = a[2] / a[1];
  if ((a[3] - a[2]) == cha) c = true;
  if ((abs(a[3] / a[2]) - bi) <= 0.000000001) b = true;
  for (register int i = 2; i < n - 1; i++) {
    if ((a[i + 1] - a[i]) != cha) c = false;
    if ((abs(a[i + 1] / a[i] - bi)) > 0.000000001) b = false;
  }
  if (c) return cout << a[n - 1] + cha, 0;
  if (b) {
    if (abs(ceil(a[n - 1] * bi) - a[n - 1] * bi) > 0.000000001)
      return cout << "42", 0;
    return cout << (int)a[n - 1] * bi, 0;
  }
  cout << "42";
  return 0;
}
