Algorithm


C. The Race
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Every year a race takes place on the motorway between cities A and B. This year Vanya decided to take part in the race and drive his own car that has been around and bears its own noble name — The Huff-puffer.

So, Vasya leaves city A on the Huff-puffer, besides, at the very beginning he fills the petrol tank with α liters of petrol (α ≥ 10 is Vanya's favorite number, it is not necessarily integer). Petrol stations are located on the motorway at an interval of 100 kilometers, i.e. the first station is located 100 kilometers away from the city A, the second one is 200 kilometers away from the city A, the third one is 300 kilometers away from the city A and so on. The Huff-puffer spends 10 liters of petrol every 100 kilometers.

Vanya checks the petrol tank every time he passes by a petrol station. If the petrol left in the tank is not enough to get to the next station, Vanya fills the tank with α liters of petrol. Otherwise, he doesn't stop at the station and drives on.

For example, if α = 43.21, then the car will be fuelled up for the first time at the station number 4, when there'll be 3.21 petrol liters left. After the fuelling up the car will have 46.42 liters. Then Vanya stops at the station number 8 and ends up with 6.42 + 43.21 = 49.63 liters. The next stop is at the station number 129.63 + 43.21 = 52.84. The next stop is at the station number 17 and so on.

You won't believe this but the Huff-puffer has been leading in the race! Perhaps it is due to unexpected snow. Perhaps it is due to video cameras that have been installed along the motorway which register speed limit breaking. Perhaps it is due to the fact that Vanya threatened to junk the Huff-puffer unless the car wins. Whatever the reason is, the Huff-puffer is leading, and jealous people together with other contestants wrack their brains trying to think of a way to stop that outrage.

One way to do this is to mine the next petrol station where Vanya will stop. Your task is to calculate at which station this will happen and warn Vanya. You don't know the α number, however, you are given the succession of the numbers of the stations where Vanya has stopped. Find the number of the station where the next stop will be.

Input

The first line contains an integer n (1 ≤ n ≤ 1000) which represents the number of petrol stations where Vanya has stopped. The next line has n space-separated integers which represent the numbers of the stations. The numbers are positive and do not exceed 106, they are given in the increasing order. No two numbers in the succession match. It is guaranteed that there exists at least one number α ≥ 10, to which such a succession of stops corresponds.

Output

Print in the first line "unique" (without quotes) if the answer can be determined uniquely. In the second line print the number of the station where the next stop will take place. If the answer is not unique, print in the first line "not unique".

Examples
input
Copy
3
1 2 4
output
Copy
unique
5
input
Copy
2
1 2
output
Copy
not unique
Note

In the second example the answer is not unique. For example, if α = 10, we'll have such a sequence as 123, and if α = 14, the sequence will be 124.

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <cstdio>
#include <set>

int main(){

    const long B = 1e6 + 7;

    long n; scanf("%ld", &n);
    std::set<long> s;
    long mx(0);
    for(long p = 0; p < n; p++){long x; scanf("%ld", &x); s.insert(x); mx = (mx > x) ? mx : x;}
    double lower(1.0), upper(B), ref(0);
    for(long p = 1; p <= mx; p++){
        double cand = (p + 1.0) / (ref + 1.0);
        if(s.count(p)){upper = (upper < cand) ? upper : cand; ++ref;}
        else{lower = (lower > cand) ? lower : cand;}
    }

    if((1 + n) * (upper - lower) >= 1){puts("not unique");}
    else{
        puts("unique");
        long next = (1 + ref) * lower;
        printf("%ld\n", next);
    }

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
3
1 2 4

Output

x
+
cmd
unique
5
Advertisements

Demonstration


Codeforces Solution-C. The Race-Solution in C, C++, Java, Python

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+