#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e18;
ifstream Cin("input.txt");
ofstream Cout("output.txt");
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (b - a == c - b && b - a == d - c)
    cout << d + (b - a);
  else if (b * 1. / a == c * 1. / b && b * 1. / a == d * 1. / c &&
           (b * 1. / a) * d == (int)((b * 1. / a) * d))
    cout << (b * 1. / a) * d;
  else
    cout << 42;
}
