#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[4];
  int d;
  double q;
  scanf("%d%d%d%d", a + 0, a + 1, a + 2, a + 3);
  if (a[3] - a[2] == a[2] - a[1] && a[2] - a[1] == a[1] - a[0]) {
    d = a[1] - a[0];
    printf("%d\n", a[3] + d);
  } else if ((double)(a[3] * 1.0 / a[2]) == (double)(a[2] * 1.0 / a[1]) &&
             (double)(a[2] * 1.0 / a[1]) == (double)(a[1] * 1.0 / a[0])) {
    q = (double)a[2] / a[1];
    double next = a[3] * q;
    if (fabs(next - (double)((int)(next))) < 1e-9)
      printf("%d\n", (int)next);
    else
      printf("42\n");
  } else
    printf("42\n");
  return 0;
}
