#K41232. Product Except Self

    ID: 26820 Type: Default 1000ms 256MiB

Product Except Self

Product Except Self

You are given an array of n integers. Your task is to produce an array output such that each output element at index i is equal to the product of all the numbers in the original array except the one at i.

The solution should work even if the array contains zero or negative numbers. The challenge must be solved with a time complexity of O(n) and should not use division.

Mathematically, if the input array is \(A = [a_0, a_1, \dots, a_{n-1}]\), then the output array \(B\) should be:

\[ B_i = \prod_{\substack{0 \leq j

inputFormat

The first line contains an integer n, the number of elements in the array.

The second line contains n space-separated integers representing the array.

outputFormat

Output a single line containing n space-separated integers. The i-th integer should represent the product of all elements in the array except the one at index i.

## sample
5
1 2 3 4 5
120 60 40 30 24

</p>