#W0002. 匹配喵
匹配喵
Background
"Finding opponents of equal skill for you..."
"I'm matched against AtomFirst? Is this real?"
"Trust me, you'll win."
Koala is dissatisfied with the matchmaking mechanism of a certain competitive game and has sought your help. He has come up with a brilliant matchmaking algorithm: ban one player.
The smaller the range of player skills, the better the matchmaking quality. By removing any one player, your task is to find the minimum possible range of the remaining players' skills.
Definition of Range: The difference between the maximum and minimum values in a set of numbers.
Problem Statement
There are players, each with a given skill level . You can remove any one player.
Calculate the minimum possible range of the remaining players' skills.
Input Format
- The first line contains a single integer (), the number of players.
- The second line contains integers (), the skill levels of the players.
Output Format
Output a single non-negative integer, representing the minimum range of the remaining players' skills after removing one player.
Sample #1
Sample Input #1
4
1 2 4 8
Sample Output #1
3
Explanation for Sample #1
By removing the player, the range of the remaining players is , which is the smallest possible.