#include <bits/stdc++.h>
using namespace std;
int main() {
  int c0, c1, c2, c3;
  cin >> c0 >> c1 >> c2 >> c3;
  if (c1 - c0 == c2 - c1 && c2 - c1 == c3 - c2) {
    cout << c3 + c1 - c0 << endl;
  } else if (c1 * c1 == c0 * c2 && c2 * c2 == c1 * c3 && !((c3 * c3) % c2)) {
    cout << c3 * c1 / c0 << endl;
  } else {
    cout << 42 << endl;
  }
}
