#C13104. Next Term in a Geometric Sequence

    ID: 42606 Type: Default 1000ms 256MiB

Next Term in a Geometric Sequence

Next Term in a Geometric Sequence

You are given a sequence of n real numbers. The sequence is expected to be a geometric progression, i.e. there exists a constant ratio \(r\) such that for every \(i\) with \(2 \le i \le n\),

[ r = \frac{a_i}{a_{i-1}} ]

Your task is to compute and output the next term of the sequence, which is \(a_{n+1} = a_n \times r\). If the input sequence is not geometric (i.e. it fails to have a constant ratio for all consecutive pairs), output the exact error message:

Error: The provided sequence is not geometric.

Note: Use exact arithmetic comparisons for the ratio. Assume the input is such that potential floating point precision issues will not affect the result.

inputFormat

The input is read from standard input. The first line contains an integer n (\(n \ge 2\)) representing the number of terms in the sequence. The second line contains n space-separated real numbers which are the terms of the sequence.

outputFormat

Output to standard output. If the sequence is geometric, print a single value representing \(a_{n+1}\) (the next term in the sequence). Otherwise, print the error message exactly as:

Error: The provided sequence is not geometric.
## sample
4
2 6 18 54
162