#include <bits/stdc++.h>
using namespace std;
signed long long a, b, c, d;
namespace lele {
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
}  // namespace lele
int main() {
  ios::sync_with_stdio(false);
  a = lele::read(), b = lele::read(), c = lele::read(), d = lele::read();
  if (a - b == b - c && b - c == c - d) {
    cout << d - a + b;
    return 0;
  } else if (a * c == b * b && b * d == c * c && d * d % c == 0)
    cout << d * d / c;
  else
    cout << 42;
  return 0;
}
