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