#C12719. Product of Array Except Self

    ID: 42177 Type: Default 1000ms 256MiB

Product of Array Except Self

Product of Array Except Self

Given an array of n integers, construct an output array such that each element at index i is equal to the product of all the elements of the original array except the one at index i. In other words, for an input array A, compute an array output where:

\( output[i] = \prod_{\substack{0 \leq j < n \\ j \neq i}} A[j] \)

You are not allowed to use division in your solution. The input is provided via standard input (stdin) and the result should be printed on standard output (stdout) as space-separated integers. Handle edge cases such as a single element array or arrays containing zeros and negative numbers.

inputFormat

The first line of input contains an integer n indicating the number of elements in the array. The second line contains n space-separated integers representing the array elements.

outputFormat

Output a single line containing n space separated integers where the i-th integer is the product of all elements of the input array except the one at index i.

## sample
4
1 2 3 4
24 12 8 6