#include <bits/stdc++.h>
int main() {
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  int p = b - a;
  if (c - b == p && d - c == p) {
    printf("%d\n", d + p);
    return 0;
  }
  if (!a || !b || !c || !d) {
    puts("42");
    return 0;
  }
  double t = double(b) / a;
  if (double(c) / b == t && double(d) / c == t && d * t == floor(d * t)) {
    printf("%.0f\n", d * t);
    return 0;
  }
  puts("42");
  return 0;
}
