#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const double eps = 1e-8;
const int maxn = 30000;
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
int main() {
  int a, b, c, d;
  while (cin >> a >> b >> c >> d) {
    int i = b - a;
    int j = c - b;
    int k = d - c;
    if (i == j && j == k) {
      printf("%d\n", d + i);
      continue;
    }
    double ii = b / (double)a;
    double jj = c / (double)b;
    double kk = d / (double)c;
    if (jj == kk && ii == jj) {
      int t = b;
      b = b / gcd(a, b);
      a = a / gcd(a, t);
      if (d % a == 0) {
        printf("%d\n", d / a * b);
        continue;
      }
    }
    cout << 42 << endl;
  }
  return 0;
}
