#C850. Product of Array Except Self

    ID: 52489 Type: Default 1000ms 256MiB

Product of Array Except Self

Product of Array Except Self

You are given an integer n (n > 1) and an array of n integers. Your task is to compute a new array such that the element at each index i is equal to the product of all the numbers in the original array except the one at i.

Note: The solution must be achieved without using division and should run in O(n) time.

Mathematical Formulation:
For an array \( A = [a_0, a_1, \dots, a_{n-1}] \), construct an output array \( B \) where

\( B[i] = \prod_{\substack{0 \le j < n \\ j \ne i}} a_j \)

inputFormat

The first line contains an integer n (n > 1) indicating the number of elements in the array.
The second line contains n space-separated integers representing the array elements.

outputFormat

Output a single line with n space-separated integers where the i-th integer is the product of all the array elements except the one at i.

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