#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  double n, i, j, k, a, b, c, d;
  bool ok = true;
  cin >> a >> b >> c >> d;
  if (a + 2 * (b - a) == c && a + 3 * (b - a) == d) {
    cout << a + 4 * (b - a);
  } else if (b * (b / a) != c || (c * (b / a) != d))
    cout << 42;
  else {
    double x = d * (b / a) * 100;
    int y = (int)(x / 100);
    k = double(y);
    if (x / 100 != k)
      cout << 42;
    else
      cout << x / 100;
  }
  return 0;
}
