#C14374. Product of Array Except Self

    ID: 44016 Type: Default 1000ms 256MiB

Product of Array Except Self

Product of Array Except Self

Given an integer array A of size n, compute an output array B such that:

\( B_i = \prod_{\substack{0 \leq j < n \\ j \neq i}} A_j \)

You must solve this without using division. The solution should run in O(n) time using a prefix and suffix product approach.

inputFormat

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

outputFormat

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

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