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