#include <bits/stdc++.h>
int main(void) {
  long s = 42, a, b, c, d, z;
  scanf("%ld%ld%ld%ld", &a, &b, &c, &d);
  ldiv_t I;
  if (c - b == (z = b - a) && d - c == z)
    s = z + d;
  else if (b && b * b == a * c && c * c == b * d && !(I = ldiv(d * d, c)).rem)
    s = I.quot;
  printf("%ld", s);
  return 0;
}
