#include <bits/stdc++.h>
using namespace std;
void solve(int testcase) {
  float a, b, c, d;
  cin >> a >> b >> c >> d;
  if (b - a == c - b && c - b == d - c) {
    cout << fixed << setprecision(0) << d + (d - c) << "\n";
  } else if (b / a == c / b && c / b == d / c) {
    if (ceil(d * (d / c)) == floor(d * (d / c))) {
      cout << fixed << setprecision(0) << d * (d / c) << "\n";
    } else
      cout << "42\n";
  } else {
    cout << "42\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve(i);
  }
}
