#include <bits/stdc++.h>
using namespace std;
bool cmp(double a, double b) {
  if (fabs(a - b) <= 0.000000001)
    return true;
  else
    return false;
}
bool z(double a) {
  long long b = (long long)a;
  if (fabs(a - b) <= 0.0000000001)
    return true;
  else
    return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  long long n = 4;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  bool f = true;
  long long dif = a[1] - a[0];
  for (long long i = 2; i < n; i++) {
    if (a[i] - a[i - 1] != dif) f = false;
  }
  if (f) {
    cout << a[3] + dif;
    return 0;
  }
  f = true;
  double mul = (double)a[1] / a[0];
  for (long long i = 2; i < n; i++) {
    if (!cmp((double)a[i] / a[i - 1], mul)) f = false;
  }
  if (f && z(a[3] * mul)) {
    cout << a[3] * mul;
  } else
    cout << 42;
}
