#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int maxn = 1e2 + 5;
bool eq(double a, double b) {
  if (fabs(a - b) <= 1e-3)
    return 1;
  else
    return 0;
}
bool is_int(double a) {
  while (a > 0) {
    a = a - 1.0;
  }
  if (eq(a, 0.0) || eq(a, -1.0)) {
    return 1;
  } else
    return 0;
}
int main() {
  double a, b, c, d;
  scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
  if (eq(b - a, c - b) && eq(c - b, d - c)) {
    if (d - c + d > 0) {
      printf("%d", int(d - c + d + 0.1));
    } else {
      printf("%d", int(d - c + d - 0.1));
    }
  } else if (eq(b / a, c / b) && eq(c / b, d / c)) {
    if (is_int(d * (d / c)))
      printf("%d", int(d * (d / c) + 0.4));
    else
      printf("42");
  } else {
    printf("42");
  }
  return 0;
}
