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