import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { 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(); } Arrays.sort(a); int smallest = Math.abs(a[0]-a[1]); for (int i = 1; i < n-1; i++) { int x = Math.abs(a[i]-a[i+1]); if (x < smallest) smallest = x; } System.out.println(smallest); } /*public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int a = in.nextInt(); int aa = Math.abs(a); int b = in.nextInt(); int bb = Math.abs(b); if (aa > bb) { int pom = a; a = b; b = pom; pom = aa; aa = bb; bb = pom; } for (int i = 2; i < n; i++){ int x = in.nextInt(); int xx = Math.abs(x); if (xx < bb) { b = x; bb = xx; if (bb < aa) { int pom = a; a = b; b = pom; pom = aa; aa = bb; bb = pom; } } } System.out.println(Math.abs(a-b)); }*/ /* 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(); } int smallest = 2000000000; for (int i = 0; i < n-1; i++) { if (a[i] < -10 && a[i] > 10) continue; for (int j = i+1; j < n; j++) { if (a[j] < -10 && a[j] > 10) continue; int x = Math.abs(a[i]-a[j]); if (x < smallest) { smallest = x; } } } System.out.println(smallest); }*/ }