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