#include <bits/stdc++.h>
using namespace std;
int main() {
  ifstream in("input.txt");
  int a[4], i;
  float kq = 42;
  bool zero = false;
  for (i = 0; i < 4; i++) {
    cin >> a[i];
    if (a[i] == 0) zero = true;
  }
  float temp = a[3] - a[2];
  if (temp == a[2] - a[1] && temp == a[1] - a[0])
    kq = a[3] + temp;
  else if (!zero) {
    temp = (float)a[3] / a[2];
    if (temp == (float)a[2] / a[1] && temp == (float)a[1] / a[0])
      kq = (float)temp * a[3];
    if (kq != ceil(temp * a[3])) kq = 42;
  }
  cout << kq;
}
