#K45192. Product Except Self

    ID: 27699 Type: Default 1000ms 256MiB

Product Except Self

Product Except Self

You are given an array of n integers. Your task is to compute a new array such that the element at each index i is the product of all the numbers in the original array except the one at index i. Formally, for an array a, you should compute an array res where:

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

Note: If the array contains exactly one element, then output 0.

This problem tests your ability to perform array manipulation and product accumulations in an efficient way.

inputFormat

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

outputFormat

Print the resulting array as space-separated integers in one line.

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