#include <bits/stdc++.h>
int main() {
  int a[4], i, test, flag = 1, flag2 = 1;
  double test2, testn;
  for (i = 0; i < 4; i++) scanf("%d", &a[i]);
  test = a[1] - a[0];
  if (a[2] - a[1] == test && a[3] - a[2] == test) {
    printf("%d", a[3] + test);
    flag = 0;
    flag2 = 0;
  }
  if (flag) {
    test2 = (double)a[1] / a[0];
    if (fabs((double)a[2] / a[1] - test2) < 0.001 &&
        fabs((double)a[3] / a[2] - test2) < 0.001) {
      testn = a[3] * test2;
      if (fabs(testn - (int)testn) < 0.001) {
        printf("%.0f", testn);
        flag2 = 0;
      }
    }
  }
  if (flag2) printf("42");
  return 0;
}
