#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, e;
int main() {
  scanf("%d%d%d%d", &a, &b, &c, &d);
  if (2 * b - a - c == 0 && 2 * c - b - d == 0) {
    printf("%d\n", 2 * d - c);
    return 0;
  }
  if (a == 0 || b == 0 || c == 0 || d == 0 || a == b || b == c || c == d) {
    printf("42\n");
    return 0;
  }
  if (b * b - a * c == 0 && c * c - b * d == 0) {
    e = (d * b) / a;
    if (d * d == c * e)
      printf("%d\n", e);
    else
      printf("42\n");
  } else
    printf("42\n");
  return 0;
}
