#include <bits/stdc++.h>
using namespace std;
int A[4], D[4];
double F[4], R[4];
bool eq(double a, double b) { return a - b < 1e-8 && b - a < 1e-8; }
void done(int x) {
  printf("%d\n", x);
  exit(0);
}
int main() {
  for (int i = 0; i < 4; ++i) scanf("%d", &A[i]);
  for (int i = 1; i < 4; ++i) D[i] = A[i] - A[i - 1];
  if (D[1] == D[2] && D[2] == D[3]) done(A[3] + D[3]);
  for (int i = 0; i < 4; ++i)
    if (A[i] == 0) done(42);
  for (int i = 0; i < 4; ++i) {
    F[i] = A[i];
    if (i) R[i] = F[i] / F[i - 1];
  }
  if (!eq(R[1], R[2]) || !eq(R[2], R[3]) || !eq(R[1], R[3])) done(42);
  if (A[3] * A[3] / A[2] == (double)A[3] * A[3] / A[2])
    done(A[3] * A[3] / A[2]);
  else
    done(42);
}
