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