import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { private static final Random RNG = new Random(); private static void swap(int[] array, int i, int j) { if (i != j) { int tmp = array[i]; array[i] = array[j]; array[j] = tmp; } } private static int partition(int[] array, int left, int right) { int randIndex = left + RNG.nextInt(right - left); swap(array, right, randIndex); int i = left - 1; for (int j = left; j < right; ++j) { if (array[j] < array[right]) { ++i; swap(array, i, j); } } ++i; swap(array, i, right); return i; } private static void quicksort(int[] array, int left, int right) { if (left < right) { int partitionIndex = partition(array, left, right); quicksort(array, left, partitionIndex - 1); quicksort(array, partitionIndex + 1, right); } } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] a = new int[n]; for(int a_i=0; a_i < n; a_i++){ a[a_i] = in.nextInt(); } // Sort values quicksort(a, 0, n - 1); // Find minimum difference between two consecutive values int minDifference = Integer.MAX_VALUE; for (int i = 1; i < n; ++i) { if ((a[i] - a[i - 1]) < minDifference) { minDifference = a[i] - a[i - 1]; } } System.out.println(minDifference); } }