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