#include <bits/stdc++.h>
int main() {
  int x1, x2, x3, x4, x5, operation_code = 0, test_code = 0, t;
  int gap1, gap2, gap3;
  float dvd1, dvd2, dvd3;
  scanf("%d%d%d%d", &x1, &x2, &x3, &x4);
  gap1 = x2 - x1;
  gap2 = x3 - x2;
  gap3 = x4 - x3;
  if (gap1 == gap2 && gap2 == gap3) {
    operation_code = 1;
    goto te;
  }
  if (x1 >= x2) {
    dvd1 = (float)x1 / (float)x2;
    dvd2 = (float)x2 / (float)x3;
    dvd3 = (float)x3 / (float)x4;
    test_code = 1;
  } else if (x1 < x2) {
    dvd1 = (float)x2 / (float)x1;
    dvd2 = (float)x3 / (float)x2;
    dvd3 = (float)x4 / (float)x3;
    test_code = 2;
  }
  if (dvd1 != dvd2 || dvd2 != dvd3 || dvd1 != dvd3) {
    operation_code = 0;
    goto te;
  }
  if (test_code == 1 &&
      ((float)x4 * dvd3 != (float)x3 || (float)x3 * dvd2 != (float)x2 ||
       (float)x2 * dvd1 != (float)x1)) {
    operation_code = 0;
    goto te;
  } else if (test_code == 1) {
    x5 = x4 / dvd1;
    t = dvd1 * x5;
    if (t != x4)
      operation_code = 0;
    else
      operation_code = 2;
    goto te;
  }
  if (test_code == 2 &&
      ((float)x3 * dvd3 != (float)x4 || (float)x2 * dvd2 != (float)x3 ||
       (float)x1 * dvd1 != (float)x2)) {
    operation_code = 0;
    goto te;
  } else if (test_code == 2) {
    x5 = x4 * dvd1;
    if (x5 / dvd1 != x4)
      operation_code = 0;
    else
      operation_code = 2;
    goto te;
  }
te:
  if (operation_code == 0)
    printf("42\n");
  else if (operation_code == 1)
    printf("%d\n", x4 + gap1);
  else if (operation_code == 2)
    printf("%d\n", x5);
  return 0;
}
