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