#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[4];
  for (int i = 0; i < 4; i++) cin >> a[i];
  bool arithm = true;
  for (int i = 2; i < 4; i++) {
    if (a[i] - a[i - 1] != a[1] - a[0]) arithm = false;
  }
  if (arithm) {
    cout << a[3] + a[1] - a[0];
  } else {
    bool geom = true;
    for (int i = 2; i < 4; i++) {
      if (a[i] * a[i - 2] != a[i - 1] * a[i - 1]) geom = false;
    }
    if (geom && a[0] != a[1] && a[0] != 0 && (a[3] * a[1]) % a[0] == 0) {
      cout << (a[3] * a[1]) / a[0];
    } else
      cout << 42;
  }
  return 0;
}
