PROBLEM B: OPTIMAL MEETING POINT OF THE TEAMS

View as PDF

Submit solution

Points: 50.00
Time limit: 1.0s
Memory limit: 256M
Input: stdin
Output: stdout

Author:
Suggester:
Problem type

The TCUPC (Telecommunications University Programming Contest) is coming up. The TCU teams have decided to meet there, but they are currently in different houses and quite far from each other, so choosing a house to meet is not easy.

They want to choose a house to meet so that the total distance that everyone has to travel is the least. In other words, they want to choose a house from the list as the meeting point, so that the total distance that everyone has to travel is the smallest.

The distance between two houses i, j is defined as: ~|P_i-P_j|~ .Where |X∣ is the absolute value of X.

You need to find and print out the most suitable house P_i, that is, the house that makes the total distance the smallest.

Input: Input from the standard device has the following format:

  • The first line contains an integer N (1 ≤ N ≤ 2×~10^5~) - the length of the array. Knowing that N is an odd number.
  • The second line contains N integers ~P_1, P_2,…, P_N~ (~1 ≤ P_i ≤ 10^9~) - the locations of the houses.

Output: Write to the standard device a single integer which is the value ~P_i~ of the optimal house.

Exam:

Input

5
7 3 5 1 4

Output

4

Comments

Please read the guidelines before commenting.


There are no comments at the moment.