#C9939. Product of Sums in an Array
Product of Sums in an Array
Product of Sums in an Array
You are given an array of n integers. Your task is to compute the product of the sum of the first half and the sum of the second half of the array. In particular, if n is odd, then the middle element is included in the second half.
Formally, let the array be \( a_0, a_1, \dots, a_{n-1} \). Define \( m = \lfloor n/2 \rfloor \). Then, the first half consists of the elements \( a_0, a_1, \dots, a_{m-1} \), and the second half consists of the elements \( a_m, a_{m+1}, \dots, a_{n-1} \). You are required to compute:
[ S = \left(\sum_{i=0}^{m-1} a_i\right) \times \left(\sum_{i=m}^{n-1} a_i\right). ]
For example, if you have an array of 6 elements: [1, 2, 3, 4, 5, 6], then the product is \((1+2+3)\times(4+5+6) = 6 \times 15 = 90\). Similarly, for an odd-length array like [1, 2, 3, 4, 5], the product is \((1+2)\times(3+4+5) = 3 \times 12 = 36\>.
inputFormat
The input is given via standard input. The first line contains an integer n (the number of elements in the array). The second line contains n space-separated integers representing the elements of the array.
outputFormat
Output the product of the sum of the first half of the array and the sum of the second half of the array to standard output.
## sample6
1 2 3 4 5 6
90