#include <bits/stdc++.h>
using namespace std;
int main() {
  double nums[4];
  double d, q;
  for (int i = 0; i < 4; i++) cin >> nums[i];
  d = nums[1] - nums[0];
  q = nums[1] / nums[0];
  if (nums[2] == nums[1] + d && nums[3] == nums[2] + d) {
    if (static_cast<int>(nums[3] + d) == (nums[3] + d))
      cout << nums[3] + d << endl;
    else
      cout << 42 << endl;
  } else if (nums[2] == nums[1] * q && nums[3] == nums[2] * q) {
    if (static_cast<int>(nums[3] * q) == (nums[3] * q))
      cout << nums[3] * q << endl;
    else
      cout << 42 << endl;
  } else {
    cout << 42 << endl;
  }
}
