#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int x;
int main() {
  while (cin >> x) {
    a.push_back(x);
  }
  if (((a[3] - a[2]) == (a[2] - a[1])) && ((a[2] - a[1]) == (a[1] - a[0]))) {
    cout << a[3] + a[3] - a[2] << endl;
    return 0;
  } else {
    if (a[0] != 0) {
      if (a[1] != 0) {
        if (a[1] != a[0]) {
          if ((((double)a[1] / a[0]) == ((double)a[2] / a[1])) &&
              (((double)a[2] / a[1]) == ((double)a[3] / a[2]))) {
            if ((int)(a[3] * ((double)a[3] / a[2])) ==
                (a[3] * ((double)a[3] / a[2]))) {
              cout << a[3] * ((double)a[3] / a[2]) << endl;
              return 0;
            }
          }
        }
      }
    }
  }
  cout << 42 << endl;
  return 0;
}
