#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  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;
}
