Skip to main content
LIVE CONTEST: ALGOR Contest: Round #4 (Special Challenge) is live now!

~/algor $ cat problems/minmax-33-bittasiz-eng-kichik-oraliq

Smallest range without one

Medium 1000 ms 128 MB 56%
Share

A positive integer $N$ and $N$ integers are given. Exactly one element must be removed from the sequence so that the difference between the largest and the smallest of the remaining elements is as small as possible. Find this smallest difference.

The difference between the largest and the smallest remaining elements after removing one

Input

The first line contains a positive integer $N$. The next line contains $N$ integers $A_{i}$.

Output

One integer.

Note

$2 \le N \le 10^{5}$
$-10^{9} \le A_{i} \le 10^{9}$

Examples

Input #1
5
2 9 5 7 6
Output #1
4
Input #2
2
-3 10
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.