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