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