#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
double a[5];
double is_dc() {
  for (int i = 1; i < 3; i++)
    if (a[i] - a[i - 1] != a[i + 1] - a[i]) return INF;
  return a[1] - a[0];
}
double is_db() {
  for (int i = 1; i < 3; i++)
    if (a[i] / a[i - 1] != a[i + 1] / a[i]) return INF;
  return a[1] / a[0];
}
int main() {
  while (scanf("%lf%lf%lf%lf", a, a + 1, a + 2, a + 3) != EOF) {
    if (is_dc() != INF) {
      printf("%.0lf\n", a[3] + is_dc());
    } else if (is_db() != INF) {
      double t = is_db() * a[3];
      if (t - floor(t) == 0) {
        printf("%.0lf\n", t);
      } else
        puts("42");
    } else
      puts("42");
  }
  return 0;
}
