#include <bits/stdc++.h>
using namespace std;
int main() {
  bool made = false;
  int x1, x2, x3, x4;
  cin >> x1 >> x2 >> x3 >> x4;
  bool f1a = (x2 - x1) == (x3 - x2) && (x3 - x2) == (x4 - x3) &&
             (x4 == (x1 + 3 * (x2 - x1)));
  bool f2g = (float(x2) / x1) == (float(x3) / x2) &&
             (float(x3) / x2) == (float(x4) / x3);
  if (f1a) {
    cout << x1 + 4 * (x2 - x1);
    made = true;
  } else {
    if (f2g && !made) {
      if (x4 * (float(x4) / float(x3)) == int(x4 * (float(x4) / float(x3)))) {
        cout << x4 * (float(x4) / float(x3)) << endl;
        made = true;
      }
    }
    if (!made) cout << 42 << endl;
  }
  return 0;
}
