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