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