cho.sh
Notes
Loading...

IQ Test

Time limit

2s

Memory limit

128 MB

Problem

You are given an integer sequence. Determine the next value under a rule of the form next term = previous term * a + b, where both a and b are integers.

If the next value is uniquely determined, print that value. If several next values are possible, print A. If no integer pair a, b can generate the given sequence, print B.

Input

The first line contains N, a positive integer not greater than 50. The second line contains N integers separated by spaces. The absolute value of each integer is at most 100.

Output

Print the next value. If several next values are possible, print A. If the next value cannot be determined because the sequence cannot be generated by any valid rule, print B.