Question
Product of Array Except Self - 2

You are given an array of N integers A_1, A_2, ..., A_N.

For each index i, compute the product of all elements in the array except A_i.

You must solve this without using the division operator anywhere in your solution, and your solution must run in O(N) time.

Input

The first line contains a single integer KaTeX can only parse string typed expression — the size of the array.

The second line contains KaTeX can only parse string typed expression integers KaTeX can only parse string typed expression.

Output

Print KaTeX can only parse string typed expression integers separated by spaces — the product of all elements except KaTeX can only parse string typed expression, for each index KaTeX can only parse string typed expression in order.

Example
Example 1:
Input
4

1 2 3 4
Output
24 12 8 6
Explanation
For index 1 (value 1), the product of the rest is KaTeX can only parse string typed expression. For index 2 (value 2), it is KaTeX can only parse string typed expression, and so on.

Example 2:
Input
5

-1 1 0 -3 3
Output
0 0 9 0 0
Explanation
Since the array contains a KaTeX can only parse string typed expression, every product except the one excluding that zero itself becomes KaTeX can only parse string typed expression. Only the position of the zero itself yields a nonzero product, from multiplying all the other elements together.

Example 3:
Input
3

2 3 5
Output
15 10 6
Explanation
KaTeX can only parse string typed expression, KaTeX can only parse string typed expression, KaTeX can only parse string typed expression.

Online