#K67332. Product Except Self

    ID: 32619 Type: Default 1000ms 256MiB

Product Except Self

Product Except Self

Given a list of n integers, compute a new list of products such that the element at index i is the product of all numbers in the list except the one at index i.

Formally, if the input array is \( a = [a_1, a_2, \dots, a_n] \), you need to compute an output array \( b \) where:

\( b_i = \prod_{\substack{1 \leq j \leq n \\ j \neq i}} a_j \)

You are required to implement a solution which reads data from stdin and writes the result to stdout. The input will first provide an integer n indicating the number of elements, followed by a line containing the n integers. The output should be a single line with n numbers separated by spaces.

inputFormat

The first line contains an integer n (1 ≤ n ≤ 10^5), the number of elements in the array. The second line contains n space-separated integers where each integer can be any 32-bit signed integer.

outputFormat

Print a single line containing n space-separated integers, where the i-th integer is the product of all array elements except the i-th element.

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

</p>