#include <bits/stdc++.h>
using namespace std;
int main() {
  int s[5];
  int i;
  int flag = -2;
  for (i = 0; i < 4; i++) cin >> s[i];
  float a = s[0];
  float b = s[1];
  float c = s[2];
  float d = s[3];
  int ans = 42;
  if (((b - a) == (c - b)) && ((c - b) == (d - c)))
    ans = d + (d - c);
  else if ((b / a) == (c / b) && (c / b) == (d / c)) {
    if (d * (b / a) == (int)(d * (b / a))) {
      ans = d * (b / a);
    }
  }
  cout << ans << "\n";
  return 0;
}
