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