#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 nn players, each with a given skill level aia_i. 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 nn (2n1052 \leq n \leq 10^5), the number of players.
  • The second line contains nn integers aia_i (1ai1091 \leq a_i \leq 10^9), 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 4th4^{\text{th}} player, the range of the remaining players is a3a1=3a_3 - a_1 = 3, which is the smallest possible.