#include <bits/stdc++.h>
using namespace std;
int num[5];
int main() {
  int ans = 0;
  for (int i = 0; i < 4; i++) cin >> num[i];
  int pa = num[1] - num[0];
  int ok = 0;
  for (int i = 0; i < 3; i++) {
    if (num[i + 1] - num[i] != pa) break;
    if (i == 2) {
      ans = num[3] + pa;
      ok = 1;
    }
  }
  if (ans == 0) {
    for (int i = 0; i < 2; i++) {
      if (num[i] * num[i + 2] != num[i + 1] * num[i + 1]) break;
      if (i == 1)
        if (num[3] * num[3] % num[2] == 0) {
          ans = num[3] * num[3] / num[2];
          ok = 1;
        }
    }
  }
  if (!ok) ans = 42;
  cout << ans << endl;
  return 0;
}
