This page is still under construction.

Parts of this page are still being built. What you see may change.

Young Energy Is Not Enough

Time limit1sMemory limit256 MB

Summary
Partition 3N ages into N triples; each triple's energy is its median age. Minimize the spread between the largest and smallest median.
Level

Medium6 of 10

Topics
Sorting, Greedy, Binary search, Array
Solved
No attempts yet

Problem

The reality survival show is looking for the best street algorithm crew in South Korea. 3N3N college students who are said to be good at algorithms from all over the country have joined, and they will form NN crews of 3 to compete in street algorithm battles.

But computer science students have always coded alone, so the production team has to make the crews...

The production team is worried that a crew might lack young energy. So the production team will form the NN crews with the following in mind.

  • Call the median age of a crew's members, that is, the age of the second oldest of the three members, the crew's energy.
  • The production team must minimize the difference in energy between the crew with the highest energy and the crew with the lowest energy.

Find this minimized value.

Input

The first line gives NN. There are 3N3N participants in total.

The second line gives 3N3N integers separated by spaces. The ii-th integer aia_i is the age of the ii-th participant.

Output

Form the NN crews from the 3N3N participants appropriately, and output the energy difference when the difference in energy between the crew with the highest energy and the crew with the lowest energy is minimized.

Constraints

  • 1≤N≤100 0001 \le N \le 100\,000
  • 1≤ai≤100 000 0001 \le a_i \le 100\,000\,000

Examples1

  1. Example 1

    Input
    2
    21 22 23 24 25 26
    
    Expected output
    1