#C3416. Product Except Self

    ID: 46841 Type: Default 1000ms 256MiB

Product Except Self

Product Except Self

Given an integer array A of length n, construct an output array B such that each element at index i is equal to the product of all the elements of A except A[i]. Formally, for each index i,

$$B[i]=\prod_{\substack{0\leq j<n \\ j\neq i}} A[j]$$

You are not allowed to use the division operator. This ensures that the algorithm works correctly even if the input array contains zeros.

inputFormat

The first line 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

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

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