#include <bits/stdc++.h>
using namespace std;
const int MAX = 10000 + 10;
int N;
int a[MAX];
int main() {
  while (cin >> a[++N])
    ;
  --N;
  int d1 = a[2] - a[1];
  int d2 = a[3] - a[2];
  int d3 = a[4] - a[3];
  if (d1 == d2 && d2 == d3) {
    cout << a[4] + d1 << endl;
    return 0;
  }
  if (a[1] == 0 || a[2] == 0 || a[3] == 0 || a[4] == 0) {
    cout << 42 << endl;
    return 0;
  }
  double p1 = (double)a[2] / a[1];
  double p2 = (double)a[3] / a[2];
  double p3 = (double)a[4] / a[3];
  if (p1 == p2 && p2 == p3) {
    double t = a[4] * p3;
    if (abs(round(t) - t) < 1e-10)
      cout << round(t) << endl;
    else
      cout << 42 << endl;
  } else
    cout << 42 << endl;
  return 0;
}
