import java.util.Scanner; public class MinimumAbsoluteDifferenceArray2 { 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(); } quickSort(a, 0, n-1); int diff = Math.abs(a[0]-a[1]); for(int i=1; i < n; i++){ if(Math.abs(a[i]-a[i-1]) < diff){ diff = Math.abs(a[i]-a[i-1]); } if(diff == 0){ break; } } System.out.println(diff); in.close(); } static int partition(int arr[], int left, int right) { int i = left, j = right; int tmp; int pivot = arr[(left + right) / 2]; while (i <= j) { while (arr[i] < pivot) i++; while (arr[j] > pivot) j--; if (i <= j) { tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; i++; j--; } }; return i; } static void quickSort(int arr[], int left, int right) { int index = partition(arr, left, right); if (left < index - 1) quickSort(arr, left, index - 1); if (index < right) quickSort(arr, index, right); } }