#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, c = 0, q1 = 1, d1 = 1;
  float A[10], d, q;
  while (cin >> A[c]) c++;
  if (c == 4) {
    d = A[1] - A[0];
    q = A[1] / A[0];
    for (i = 2; i < 4; i++) {
      if (A[i] - A[i - 1] != d) d1 = 0;
      if (A[i] / A[i - 1] != q) q1 = 0;
    }
    if (d1) {
      cout << A[3] + d << endl;
    } else if (q1 && A[3] * q == floor(A[3] * q)) {
      cout << A[3] * q << endl;
    } else {
      c = 0;
    }
  }
  if (c < 4) cout << "42" << endl;
  return 0;
}
