#include <bits/stdc++.h>
using namespace std;
int a, b, c, d;
int main() {
  scanf("%d%d%d%d", &a, &b, &c, &d);
  if (a - b == b - c && b - c == c - d) {
    printf("%d", d - (b - c));
    return 0;
  }
  if (b - a == c - b && c - b == d - c) {
    printf("%d", d + (d - c));
    return 0;
  } else if (a * c == b * b && b * d == c * c) {
    if (!(d * d % c))
      printf("%d\n", d * d / c);
    else
      printf("%d\n", 42);
  } else
    cout << 42;
  return 0;
}
