Winning Ballot
Time limit1sMemory limit512 MB
Given N-1 values where A_i is the gcd of consecutive terms, reconstruct a sequence of N numbers below 10^18, or report that none exists.
- Level
Medium7 of 10
- Topics
- Number theory, Math, Greedy, Implementation
- Solved
- No attempts yet
Problem
Loznica is a city in Serbia, famous for its history, culture, pleasant weather, and lottery. The lottery in Loznica follows these rules:
- A ballot holds a combination of natural numbers, each smaller than .
- Numbers may repeat, and their order matters.
Aljoha, the hero of our story, used some obscure utilities to learn information about the next winning ballot. Let the future combination be , . Aljoha learned an array of numbers, in which the th number is the largest number that divides both and .
Now Aljoha wants to bet, and for that noble goal he needs help. Print one combination that satisfies the constraints, or if no such combination exists. If more than one combination satisfies the constraints, print any of them. Only combinations in which every number is strictly smaller than are valid.
Input
The first line contains the number (), the length of the combination.
The second line contains positive integers not greater than , describing the information Aljoha found.
Output
Print numbers, each strictly less than , describing some combination that satisfies the constraints, or if no such combination exists.