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