#include <bits/stdc++.h>
int main() {
  int arr[4], i, n;
  for (i = 0; i < 4; i++) scanf("%d", &arr[i]);
  if (arr[0] - arr[1] == arr[1] - arr[2] && arr[2] - arr[3] == arr[1] - arr[2])
    n = arr[3] - (arr[0] - arr[1]);
  else if (arr[3] * arr[1] == arr[2] * arr[2] &&
           arr[2] * arr[0] == arr[1] * arr[1] &&
           (arr[3] * arr[3]) % arr[2] == 0)
    n = arr[3] * arr[3] / arr[2];
  else
    n = 42;
  printf("%d\n", n);
  return 0;
}
