#include <bits/stdc++.h>
using namespace std;
double a[4];
int main() {
  for (int i = 0; i < 4; i++) {
    cin >> a[i];
  }
  bool inc = true;
  for (int i = 0; i < 2; i++) {
    if (a[i + 1] - a[i] != a[i + 2] - a[i + 1]) inc = false;
  }
  if (inc) {
    cout << a[3] + a[1] - a[0];
    return 0;
  }
  bool ex = true;
  for (int i = 0; i < 2; i++) {
    if (fabs(a[i + 1] / a[i] - a[i + 2] / a[i + 1]) > 1.0e-8) ex = false;
  }
  if (ex && fabs(a[3] * a[1] / a[0] - double(int(a[3] * a[1] / a[0] + 0.5))) <
                1.0e-8) {
    cout << a[3] * a[1] / a[0];
    return 0;
  }
  cout << 42;
  return 0;
}
