#C1763. Subset Products

    ID: 45004 Type: Default 1000ms 256MiB

Subset Products

Subset Products

Given an array of n integers, your task is to calculate all the distinct products formed by multiplying the elements of every non-empty subset of the array. Formally, for any non-empty subset S of the array, the product is defined as

\(\prod_{x \in S} x\)

You must output all unique products in increasing order.

Note: Use standard input to read the values and standard output to print the results. The order of the output must be sorted (ascending).

inputFormat

The first line contains a single integer n (1 \(\leq\) n \(\leq\) 15) representing the number of elements in the array.
The second line contains n space-separated integers, each representing an element of the array.

outputFormat

Output a single line containing all distinct subset products in increasing order, separated by a single space.

## sample
3
1 2 3
1 2 3 6