#include <bits/stdc++.h>
using namespace std;
const int N = 4e4 + 1, M = 4e4 + 1;
int main() {
  double a, b, c, d;
  cin >> a >> b >> c >> d;
  bool arth = 0, geo = 0;
  double dif = b - a;
  double r = b / a;
  if (dif == c - b and dif == d - c)
    cout << d + dif;
  else if (c / b == r and d / c == r) {
    double res = d * r;
    if (fmod(res, 1) == 0)
      cout << res;
    else
      cout << 42;
  } else
    cout << 42;
}
