#include <bits/stdc++.h>
using namespace std;
const int N = 4;
int as[N];
int main() {
  for (int i = 0; i < N; i++) scanf("%d", as + i);
  if (as[1] - as[0] == as[2] - as[1] && as[2] - as[1] == as[3] - as[2])
    printf("%d\n", as[3] + (as[3] - as[2]));
  else if (as[1] * as[1] == as[0] * as[2] && as[2] * as[2] == as[1] * as[3]) {
    int n = as[3] * as[3], d = as[2];
    if (n % d == 0)
      printf("%d\n", n / d);
    else
      puts("42");
  } else
    puts("42");
  return 0;
}
