#C10292. Product Except Self

    ID: 39481 Type: Default 1000ms 256MiB

Product Except Self

Product Except Self

You are given a list of positive integers. For each element at index i, compute the product of all the numbers in the list except the one at index i. Mathematically, the answer for each index can be written as: $$output[i] = \prod_{\substack{0 \leq j < n \\ j \neq i}} nums[j].$$

The input list is guaranteed to contain at least 2 integers.

inputFormat

The first line contains an integer n (n ≥ 2), representing the number of elements in the list. The second line contains n space-separated positive integers.

outputFormat

Print a single line with n space-separated integers. The i-th integer is the product of all numbers in the input list except the one at index i.## sample

4
1 2 3 4
24 12 8 6