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