import java.util.*; public class Run { public static void main (String arg[]) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int[] X = new int[N]; for (int i = 0; i < N; i++) { X[i] = scan.nextInt(); } heapSort(N, X); int min = X[1] - X[0]; int tmp; for (int i = 1; i < N-1; i++) { tmp = X[i+1] - X[i]; if ((min==0 && tmp!=0) || min > tmp) min = tmp; } System.out.println(min); } public static void heapSort (int leaf, int[] A) { int l = leaf; int tmp; for (int j = 0; j < l; j++) { int root = leaf/2-1; for (int i = root; i >= 0; i--) { while ((root + 1) * 2 <= leaf) { if ((root + 1) * 2 == leaf) { tmp = (root + 1) * 2 - 1; } else { if (A[(root + 1) * 2 - 1] < A[(root + 1) * 2]) tmp = (root + 1) * 2; else tmp = (root + 1) * 2 - 1; } if (A[root] < A[tmp]) { swap(A, root, tmp); root = tmp; } else break; } root = i - 1; } tmp = A[0]; A[0] = A[leaf-1]; A[leaf-1] = tmp; leaf--; } } public static void swap (int[] A, int a, int b){ int tmp; tmp = A[a]; A[a] = A[b]; A[b] = tmp; } }