#include <bits/stdc++.h>
using namespace std;
double a, b, c, d;
int main() {
  char st = 'e';
  cin >> a >> b >> c >> d;
  if (a / b == b / c && b / c == c / d) st = 'g';
  if (a - b == b - c && b - c == c - d) st = 'a';
  if (st == 'e')
    cout << 42 << endl;
  else if (st == 'g') {
    int d1 = d, b1 = b, a1 = a;
    if (d * b / a == d1 * b1 / a1)
      cout << d * b / a << endl;
    else
      cout << 42 << endl;
  } else
    cout << d + b - a << endl;
}
