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