#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long double a, b, c, d;
  cin >> a >> b >> c >> d;
  if (d - c == c - b && c - b == b - a) {
    cout << 2 * d - c;
  } else if (b / a == c / b && d / c == c / b) {
    if ((int)d * (int)d % (int)c == 0)
      cout << d * d / c;
    else
      cout << 42;
  } else
    cout << 42;
}
