import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { private int length; 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(); } Solution xx=new Solution(); xx.sort(a); int min=Math.abs(a[0]-a[1]); for(int i=1;iMath.abs(a[i]-a[i+1])) min=Math.abs(a[i]-a[i+1]); } System.out.println(min); // your code goes here } public void sort(int[] inputArr) { if (inputArr == null || inputArr.length == 0) { return; } length = inputArr.length; quickSort(0, length - 1,inputArr); } private void quickSort(int lowerIndex, int higherIndex,int array[]) { int i = lowerIndex; int j = higherIndex; int pivot = array[lowerIndex+(higherIndex-lowerIndex)/2]; while (i <= j) { while (array[i] < pivot) { i++; } while (array[j] > pivot) { j--; } if (i <= j) { exchangeNumbers(i, j,array); i++; j--; } } if (lowerIndex < j) quickSort(lowerIndex, j,array); if (i < higherIndex) quickSort(i, higherIndex,array); } private void exchangeNumbers(int i, int j,int array[]) { int temp = array[i]; array[i] = array[j]; array[j] = temp; } }