import java.util.*; import java.math.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] x = new int[N]; for(int i = 0; i < N; i++) { x[i] = sc.nextInt(); } for(int i = 0; i < N; i++) { int idx1 = (int)Math.random() * N; int idx2 = (int)Math.random() * N; int tmp = x[idx1]; x[idx1] = x[idx2]; x[idx2] = tmp; } if(N == 1) System.out.println("0"); int MIN = Integer.MAX_VALUE; Arrays.sort(x); for(int i = 0; i < N-1; i++) { if(x[i] == x[i+1]) continue; MIN = Math.min(MIN, (int)Math.abs(x[i] - x[i+1])); } if(MIN == Integer.MAX_VALUE) MIN = 0; System.out.println(MIN); } }