#C3063. Product Except Self

    ID: 46449 Type: Default 1000ms 256MiB

Product Except Self

Product Except Self

Given an array of integers, your task is to compute an output array result where each element at index i is the product of all the elements in the original array except the one at index i. In other words, you need to compute

$$result[i] = \prod_{\substack{j=0 \\ j \neq i}}^{n-1} nums[j]$$

without using division and in O(n) time.

Input example: For an input array [1, 2, 3, 4], the output should be [24, 12, 8, 6].

Note that the input will be provided via standard input (stdin) and the output should be printed to standard output (stdout).

inputFormat

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

outputFormat

Print 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>