#include <bits/stdc++.h>
using namespace std;
int main() {
  double s[4];
  for (int i = 0; i < 4; i++) {
    cin >> s[i];
  }
  if ((s[1] - s[0] == s[2] - s[1]) && (s[2] - s[1] == s[3] - s[2])) {
    s[3] + (s[1] - s[0]);
    cout << s[3] + (s[1] - s[0]);
    return 0;
  }
  if ((s[1] / s[0] == s[2] / s[1]) && (s[2] / s[1] == s[3] / s[2])) {
    s[3] * (s[1] / s[0]);
    if (s[3] * (s[1] / s[0]) > int(s[3] * (s[1] / s[0]))) {
      cout << 42;
    } else
      cout << s[3] * (s[1] / s[0]);
    return 0;
  }
  cout << "42";
  return 0;
}
