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