AlgoUniversity
  • Go Back
Discussion
Correct Gp :

Author

Akshay Sharma

Difficulty Level : Hard

Submissions : 103

Asked In : Tiktok

Marks :100

: 1 | : 1

Rohan hates maths and his teacher gives him a question related to Geometric Progression (GP). He was given an array of GP sequences which is $$$a_i$$$, $$$a_{i+1}$$$ ..... $$$a_{n-1}$$$ but his teacher wants that Rohan to come up with the correct GP sequence. The only operation he is allowed to do is insert some elements $$$a_i$$$ for which the Gp ratio between every two consecutive elements became equally. If no solution exists print -1. Also, his teacher asked him to maximise the ratio of GP.

Now Rohan needs your help to find the correct GP sequence which has a maximum ratio

Input

The first line of the test case contains a single integer N ($$$0 \le N \le 10^5$$$) — the length of sequence that teaches gave to Rohan.

The second line of each test case contains N integers $$$a_i$$$, $$$a_{i+1}$$$ ..... $$$a_{n-1}$$$ ($$$0 \le a_i \le 2*10^4$$$) — the sorted incorrect GP .

Output

For each test case print the correct sequence of the array if it exists else print -1.

Examples

Input
3
64 100 125
Output
64 80 100 125
Input
4
2 8 16 32
Output
2 4 8 16 32

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.