You are given an array a consisting of n integer numbers.

Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i.

You have to remove exactly one element from this array to minimize instability of the resulting (n-1)-elements array. Your task is to calculate the minimum possible instability.

Input

The first line of the input contains one integer n (2 ≤ n ≤ 10^5) — the number of elements in the array a.

The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^5) — elements of the array a.

Output

Print one integer — the minimum possible instability of the array if you have to remove exactly one element from the array a.

Examples

Input


4
1 3 3 7


Output


2


Input


2
1 100000


Output


0

Note

In the first example you can remove 7 then instability of the remaining array will be 3 - 1 = 2.

In the second example you can remove either 1 or 100000 then instability of the remaining array will be 100000 - 100000 = 0 and 1 - 1 = 0 correspondingly.

/**
 *
 *  @author Mustafa Arinmis
 *  @since 12.10.2020
 *
 * */

import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int len = input.nextInt();

        if(len < 3) {
            System.out.println(0);
            System.exit(0);
        }
        else if(len == 3) {
            int[] nums = new int[3];
            nums[0] = input.nextInt();
            nums[1] = input.nextInt();
            nums[2] = input.nextInt();
            Arrays.sort(nums);

            if(nums[1] - nums[0] > nums[len-1] - nums[len-2]) {
                //In this case should remove index (0)
                System.out.println(nums[len-1] - nums[1]);
                System.exit(0);
            }
            else {
                // in this case we need to remove index (len-1)
                System.out.println(nums[len-2] - nums[0]);
                System.exit(0);
            }
        }
        else if(len == 4) {
            int[] nums = new int[4];
            nums[0] = input.nextInt();
            nums[1] = input.nextInt();
            nums[2] = input.nextInt();
            nums[3] = input.nextInt();
            Arrays.sort(nums);

            if(nums[1] - nums[0] > nums[3] - nums[2]) {
                //In this case should remove index (0)
                System.out.println(nums[3] - nums[1]);
                System.exit(0);
            }
            else {
                // in this case we need to remove index (len-1)
                System.out.println(nums[2] - nums[0]);
                System.exit(0);
            }

        }

        int[] arr = new int[4];
        //this array will store min 2 nuber and max max 2 number in order

        int temp = input.nextInt();
        arr[0] = temp;
        arr[1] = temp;
        arr[2] = temp;
        arr[3] = temp;
        for(int i=1; i<len; i++) {
            temp = input.nextInt();
            if(temp <= arr[0]) {
                arr[1] = arr[0];
                arr[0] = temp;
            }else if(temp < arr[1] || i == 1)
                arr[1] = temp;

            if(temp >= arr[3]) {
                arr[2] = arr[3];
                arr[3] = temp;
            }else if(temp > arr[2])
                arr[2] = temp;

        }

    //            for(int x: arr)
    //                System.out.print(x + " - ");
    //            System.out.println();

        if(arr[1] - arr[0] > arr[3] - arr[2]) {
            //In this case should remove index (0)
             System.out.println(arr[3] - arr[1]);
        }
        else {
            // in this case we need to remove index (len-1)
            System.out.println(arr[2] - arr[0]);
        }
    }
}