#K33042. Product Except Self

    ID: 24999 Type: Default 1000ms 256MiB

Product Except Self

Product Except Self

Given an array of integers, return a new array such that each element at index \(i\) is the product of all numbers in the original array except the one at index \(i\). You must solve this problem without using division and with an overall time complexity of \(O(n)\). This problem challenges you to combine prefix and suffix products to compute the desired result, even when the array contains zeros or negative numbers.

inputFormat

The first line of input contains an integer \(n\), indicating 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. The \(i\)-th integer should be equal to the product of all numbers in the array except for the element at index \(i\).

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

</p>