#C11457. Unique Elements Product
Unique Elements Product
Unique Elements Product
Given an array of integers, your task is to compute the product of all unique elements in the array. More formally, if the array consists of elements \(a_1, a_2, \dots, a_n\), you must first extract the distinct elements in the array and then calculate their product. If the array is empty, the result should be defined as \(1\).
Note: Even if an integer appears multiple times in the array, it should be considered only once in the product calculation. For example, in the array [2, 4, 6, 2, 4], the unique elements are \(\{2, 4, 6\}\) and their product is \(2 \times 4 \times 6 = 48\).
You are required to read input from the standard input and write the answer to the standard output.
inputFormat
The input consists of two lines:
- The first line contains a single integer \(n\) (which can be zero), representing the number of elements in the array.
- The second line contains \(n\) space-separated integers, which are the elements of the array.
If \(n = 0\), the second line may be empty.
outputFormat
Output a single integer that is the product of all unique elements in the given array. If the array is empty, output \(1\).
## sample5
2 4 6 2 4
48