#include <bits/stdc++.h>
using namespace std;
const long long MX5 = 2 * 1e5 + 3;
const long long MX9 = 2 * 1e9 + 3;
const double PI = acos(-1);
double rad(double x) { return PI * x / 180; }
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (b - a == c - b && c - b == d - c) {
    cout << d + (b - a);
    return 0;
  }
  if (b == 0 || a == 0 || c == 0 || d == 0) {
    cout << 42;
    return 0;
  }
  if (b * b == c * a && c * c == d * b && a != 0) {
    if ((d * b) / a == 0 || (d * b) % a != 0)
      cout << 42;
    else
      cout << (d * b) / a;
    return 0;
  }
  cout << 42;
  return 0;
}
