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(); } // your code goes here if(n > 10){ //This segment will tell us the number of positive and negative values int neg1 = 0; int pos1 = 0; for(int i = 0 ; i < n ; i++){ if(a[i] > 0){ pos1++; } else if(a[i] <= 0){ neg1++; } } //This segment will assign all the positive values to 1 array and the negative values to the other int positive[] = new int[pos1]; int negative[] = new int[neg1]; int pos = 0; int neg = 0; for(int i = 0 ; i < n ; i++){ if(a[i] > 0){ positive[pos++] = a[i]; } else{ negative[neg++] = a[i]; } } //This segment will sort the positive array int element; for(int i = 0 ; i < pos ; i++){ element = positive[i]; int j = i; while(j > 0 && positive[j - 1] > element){ positive[j] = positive[j - 1]; j = j - 1; positive[j] = element; } } //This array will sort the negative array int random; for(int i = 0 ; i < neg ; i++){ random = negative[i]; int j = i; while(j > 0 && positive[j - 1] > random){ negative[j] = negative[j - 1]; j = j - 1; negative[j] = random; } } //This code tells us the min diff between 2 numbers in a new array int total = neg + pos; int array[] = new int[total]; for(int i = 0 ; i < neg ; i++){ array[i] = negative[i]; } for(int i = neg ; i < pos ; i++){ array[i] = positive[i]; } int min1 = 9999999; for(int i = 0 ; i < pos ; i++){ int result = Math.abs(array[i] - array[i + 1]); if(result <= min1){ min1 = result; } if(i == pos - 2){ break; } } System.out.println(min1); } else if(n <= 10){ long minDiff = 999999999; int diff = 0; for(int i = 0 ; i < n ; i++){ for(int j = i + 1 ; j < n ; j++){ diff = Math.abs(a[i] - a[j]); if(diff <= minDiff){ minDiff = diff; } } } System.out.println(minDiff); } } }