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