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