#include <bits/stdc++.h>
using namespace std;
int A[4];
int main() {
  for (int i = 0; i < 4; ++i) {
    cin >> A[i];
  }
  int d = A[1] - A[0];
  bool ok = true;
  for (int i = 2; i < 4; ++i) {
    if (A[i] - A[i - 1] != d) {
      ok = false;
      break;
    }
  }
  if (ok) {
    cout << A[3] + d << '\n';
    return 0;
  }
  ok = true;
  int a = A[1];
  int b = A[0];
  for (int i = 2; i < 4; ++i) {
    if (A[i - 1] * a != A[i] * b) {
      ok = false;
      break;
    }
  }
  if (ok) {
    int x = A[3] * a;
    if (x % b == 0) {
      cout << x / b << '\n';
      return 0;
    }
  }
  cout << "42\n";
  return 0;
}
