#include <bits/stdc++.h>
using namespace std;
int main() {
  float a, b, c, d, diff, r;
  cin >> a >> b >> c >> d;
  if ((b - a) == (c - b) && (d - c) == (c - b)) {
    diff = b - a;
    cout << d + diff;
    return 0;
  }
  if ((b / a) == (c / b) && (c / b) == (d / c)) {
    r = b / a;
    stringstream ss;
    ss << d * r;
    string str = ss.str();
    if (str.find('.') == -1)
      cout << str;
    else
      cout << 42;
    return 0;
  }
  cout << 42;
  return 0;
}
