#include <bits/stdc++.h>
using namespace std;
int main() {
  int n1, n2, n3, n4, d, q;
  cin >> n1 >> n2 >> n3 >> n4;
  if (n2 - n1 == n3 - n2 && n3 - n2 == n4 - n3)
    cout << 2 * n4 - n3 << endl;
  else if (n1 * n3 == n2 * n2 && n3 * n3 == n2 * n4 &&
           n4 * n4 == n4 * n4 / n3 * n3)
    cout << n4 * n4 / n3 << endl;
  else
    cout << 42 << endl;
  return 0;
}
