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