#K95467. Product Except Self

    ID: 38870 Type: Default 1000ms 256MiB

Product Except Self

Product Except Self

Given an array of integers, compute an output array where each element at index i is the product of all the numbers in the array except the one at index i. The solution must be implemented in O(n) time complexity without using division.

The product for each index i is defined as:

$$output[i] = \prod_{\substack{0 \leq j < n \\ j \ne i}} nums[j]$$

Ensure your program reads the input from stdin and writes the result to stdout as a space-separated list.

inputFormat

The first line contains an integer n denoting 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 the elements of the input array except the element at index i.

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

</p>