Petya is preparing for IQ test and he has noticed that there many problems like: you are given a sequence, find the next number. Now Petya can solve only problems with arithmetic or geometric progressions.

Arithmetic progression is a sequence a1, a1 + d, a1 + 2d, ..., a1 + (n - 1)d, where a1 and d are any numbers.

Geometric progression is a sequence b1, b2 = b1q, ..., bn = bn - 1q, where b1 ≠ 0, q ≠ 0, q ≠ 1. 

Help Petya and write a program to determine if the given sequence is arithmetic or geometric. Also it should found the next number. If the sequence is neither arithmetic nor geometric, print 42 (he thinks it is impossible to find better answer). You should also print 42 if the next element of progression is not integer. So answer is always integer.

Input

The first line contains exactly four integer numbers between 1 and 1000, inclusively.

Output

Print the required number. If the given sequence is arithmetic progression, print the next progression element. Similarly, if the given sequence is geometric progression, print the next progression element.

Print 42 if the given sequence is not an arithmetic or geometric progression.

Examples

Input

836 624 412 200


Output

-12


Input

1 334 667 1000


Output

1333

Note

This problem contains very weak pretests!
/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.text.ParseException;
import java.util.*;

/**
 * @author Artem_Mikhalevitch
 */
public class Main extends ASolver {

    long[] a;

    public static void main(String[] args) throws ParseException {

        Main s = new Main();
        s.init();

        if (s.readData()) {
            //s.solve();
            s.writeData("" + s.solve());

        }
    }

    @Override
    public void init() {
        super.init();
    }

    @Override
    public boolean readData() {
        try {

            a = new long[4];
            for (int i = 0; i < 4; i++) {
                a[i] = nextLong();
            }
        } catch (Exception ex) {
            System.out.println(ex.getCause());
            System.out.println(ex.getMessage());
            return false;
        }
        return true;
    }

    public double[] sort(double[] mas1, double[] mas2) {
        int l1 = mas1.length;
        int l2 = mas2.length;
        double[] result = new double[l1 + l2];
        int i1 = 0, i2 = 0;
        int i = 0;
        for (i = 0; i1 < l1 && i2 < l2; i++) {
            if (mas1[i1] <= mas2[i2]) {
                result[i] = mas1[i1++];
            } else {
                result[i] = mas2[i2++];
            }
        }
        for (int j = i; i1 < l1; j++) {
            result[j] = mas1[i1++];
        }
        for (int j = i; i2 < l2; j++) {
            result[j] = mas2[i2++];
        }
        return result;
    }

    public long solve() {
        if (isGP()) {
            double gp=(a[3] * ((0.0 + a[3]) / a[2]));
            long result = (long)gp ;
            if (result == 0 ||result!= gp ) {
                return 42l;
            }
            return result;
        }
        if (isAP()) {
            return (long) (2 * a[3] - a[2]);
        }

        return 42l;
    }

    public boolean isGP() {
        if (a[0] == 0) {
            return false;
        }
        double d = (0.0 + a[1]) / a[0];
        for (int i = 2; i < 4; i++) {
            if (a[i - 1] == 0 || ((0.0 + a[i]) / a[i - 1] != d)) {
                return false;
            }
        }
        return true;
    }

    public boolean isAP() {
        long d = a[1] - a[0];
        for (int i = 2; i < 4; i++) {
            if (a[i] - a[i - 1] != d) {
                return false;
            }
        }
        return true;
    }
    /*
     * public void buildTree(int v, int tl, int tr) { if (tl == tr) { t[v] =
     * a[tl]; } else { int tm = (tl + tr) / 2; buildTree(v * 2, tl, tm);
     * buildTree(v * 2 + 1, tm + 1, tr); t[v] = t[v * 2] + t[v * 2 + 1]; } }
     *
     * public long sum(int v, int tl, int tr, int l, int r) { if (l > r) {
     * return 0; } if (l == tl && r == tr) { return t[v]; } int tm = (tl + tr) /
     * 2; return (sum(v * 2, tl, tm, l, Math.min(r, tm))%95542721 + sum(v * 2 +
     * 1, tm + 1, tr, max(l, tm + 1), r)%95542721)%95542721; }
     *
     * public long sum(List<Integer> listForSum) { long result = 0; int size =
     * listForSum.size(); for (int i = 0; i < size; i++) { result +=
     * listForSum.get(i); } return result; }
     *
     * void update(int v, int tl, int tr, int pos) { if (tl == tr) { t[v] =
     * (t[v]*t[v]*t[v]); } else { int tm = (tl + tr) / 2; if (pos <= tm) {
     * update(v * 2, tl, tm, pos); } else { update(v * 2 + 1, tm + 1, tr, pos);
     * } t[v] = (t[v * 2] + t[v * 2 + 1]); }
        }
     */
}

abstract class ASolver {

    protected StringTokenizer tokens;
    protected BufferedReader input;
    protected PrintWriter output;

    public void init() {
        input = new BufferedReader(new InputStreamReader(System.in));
    }

    public abstract boolean readData();

    public void writeData(String result) {
        System.out.println(result);
    }

    public void writeData(int result) {
        System.out.println(result);
    }

    public void writeData(long result) {
        System.out.println(result);
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public String next() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    public String nextLine() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine(), "\n");
        }
        return tokens.nextToken();
    }

    public long infinityImitator(long a, long b) {
        if (a == Long.MIN_VALUE) {
            return Long.MIN_VALUE;
        } else {
            return a + b;
        }
    }

    public int infinityImitator(int a, int b) {
        if (a == Integer.MIN_VALUE) {
            return Integer.MIN_VALUE;
        } else {
            return a + b;
        }
    }

    /*
     * public long max(long... a) { long result = Long.MIN_VALUE; for (int i =
     * 0; i < a.length; i++) { result = Math.max(result, a[i]); } return result;
     * }
     */
    public int indexMax(int... a) {
        int result = 0;
        int index = -1;
        int length = a.length;
        for (int i = 0; i < length; i++) {
            if (a[i] > result) {
                result = a[i];
                index = i;
            }
        }
        return index;
    }

    public int indexMax(long... a) {
        long result = 0;
        int index = -1;
        int length = a.length;
        for (int i = 0; i < length; i++) {
            if (a[i] > result) {
                result = a[i];
                index = i;
            }
        }
        return index;
    }

    public int max(int... a) {
        int result = Integer.MIN_VALUE;
        for (int i = 0; i < a.length; i++) {
            result = Math.max(result, a[i]);
        }
        return result;
    }

    public long max(long... a) {
        long result = Integer.MIN_VALUE;
        for (int i = 0; i < a.length; i++) {
            result = Math.max(result, a[i]);
        }
        return result;
    }
}

class ABSComparator implements Comparator<Pair> {

    /**
     * Compares its two arguments for order. Returns a negative integer, zero,
     * or a positive integer as the first argument is less than, equal to, or
     * greater than the second.
     */
    @Override
    public int compare(Pair o1, Pair o2) {
        if (o1.getA() == o2.getA()) {
            return o2.getB() - o1.getB();
        }
        return o1.getA() - o2.getA();
    }
}

class Pair {

    int a;
    int b;
    int pos;

    public Pair() {
    }

    public Pair(int a, int b, int pos) {
        this.a = a;
        this.b = b;
        this.pos = pos;
    }

    public int getA() {
        return a;
    }

    public int getB() {
        return b;
    }

    public void setA(int a) {
        this.a = a;
    }

    public void setB(int b) {
        this.b = b;
    }

    public void setPos(int pos) {
        this.pos = pos;
    }

    public int getPos() {
        return pos;
    }
}

class ABSComparatorDesc implements Comparator<Pair> {

    /**
     * Compares its two arguments for order. Returns a negative integer, zero,
     * or a positive integer as the first argument is less than, equal to, or
     * greater than the second.
     */
    @Override
    public int compare(Pair o1, Pair o2) {
        if (o2.getB() == o1.getB()) {
            return o1.getA() - o2.getA();
        }
        return o2.getB() - o1.getB();
    }
}