Go for Gold

0

0 votes
Easy
Problem

Dr.Sankey wants to form 2-member teams for future programming contests in his university which has N students. Each student has a skill value and the total power of a team is half of the sum of skill values of the team members. He forms teams in such a manner: The 1st and 2nd highest skilled students form a team together, the 3rd and 4th highest skilled form a team together and so on. Each student would be a part of some team i.e; N/2 teams are made.

Find the average power of the teams in Dr.Sankey's university.

Input Format:

First line contains the integer N. Next line contains N integers, each denoting the skill value of ith student.

Output Format:

Output one integer which is a floored value of the floating number denoting the average power of teams in the college.

Constraints:

1 <= N <= 106

1 <= Ai <= 1017

N is always even 

All Necessary Calculation to find out the required answer can be done using a 64-bit integer.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The powers of the teams formed are : (4+3)/2 and (2+1)/2 => 3.5 and 1.5.

The average power is (3.5 + 1.5)/2 = 2.5 whose floor value is 2.

Thus, the output is 2. 

Editor Image

?