#include <bits/stdc++.h>
int main() {
  int a, b, c, d;
  int x, y, z;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  if ((a + c) == b * 2 && (b + d) == c * 2) {
    printf("%d", (2 * d) - c);
  } else if ((b * b == a * c) && (c * c == b * d) && ((d * d) % c == 0)) {
    printf("%d", (d * d) / c);
  } else
    printf("42");
  return 0;
}
