#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, f;
  cin >> a >> b >> c >> f;
  if (2 * b == a + c && 2 * c == b + f)
    cout << 2 * f - c << endl;
  else if (b * b == a * c && b * f == c * c && !(f * f % c))
    cout << f * f / c << endl;
  else
    cout << "42" << endl;
}
