#K95342. Sum of Middle Elements
Sum of Middle Elements
Sum of Middle Elements
You are given an even-sized array of integers. Your task is to compute the sum of the two middle elements. Specifically, if the array size is n, then the middle indices are \(\frac{n}{2}-1\) and \(\frac{n}{2}\). Ensure that the array has a minimum of 2 elements and that n is even.
Example: For an input array [1, 2, 3, 4, 5, 6], the middle elements are 3 and 4, so the output should be 7.
inputFormat
The input is provided through standard input (stdin) and consists of two lines:
- The first line contains an even integer n (\( n \ge 2 \)), representing the number of elements in the array.
- The second line contains n space-separated integers representing the array.
outputFormat
Output a single integer to standard output (stdout): the sum of the middle two elements of the array.
## sample6
1 2 3 4 5 6
7