public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        TreeSet<Integer> powers = new TreeSet<Integer>();

        for (int i = 0; i < n; i++) {
            int power = in.nextInt();
            if (powers.contains(power)) {
                System.out.println(0);
                return;
            }
            powers.add(power);
        }

        Integer lastPower = null;
        Integer bestDiff = Integer.MAX_VALUE;

        for (int power : powers) {
            if (lastPower != null && power - lastPower < bestDiff) {
                bestDiff = power - lastPower;
            }
            lastPower = power;
        }
        System.out.println(bestDiff);
    }