import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] x = new int[n];
        for(int i=0; i<n; i++) {
            x[i] = in.nextInt();
        }
        Arrays.sort(x);

        if(n == 1) {
            System.out.println(0);
        } else {
            int len = Integer.MAX_VALUE;
            for(int i=1; i<n; i++) {
                if(x[i] != x[i-1]) {
                    len = Math.min(len, Math.abs(x[i] - x[i-1]));
                }
            }

            if(len == Integer.MAX_VALUE) {
                System.out.println(0);
            } else {
                System.out.println(len);
            }
        }

        in.close();
    }
}