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