LogiQuest

41. Product of Array Except Self

MediumArrayPrefix Products

For each position, print the product of all other elements, without using division.

Input format

Line 1: n Line 2: n integers

Output format

n space-separated products.

Example 1

Input

4
1 2 3 4

Output

24 12 8 6

Example 2

Input

5
-1 1 0 -3 3

Output

0 0 9 0 0

Constraints

2 ≤ n ≤ 10⁵, products fit in a 32-bit integer

Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.

Loading the MyLoginn IDE…