import java.util.Arrays;
import java.util.Scanner;
/**
* 思路:先排序,再取左右相减取绝对值的最小值
*/
public class Main{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] nn = new int[n];
for (int i = 0; i < n; i++) {
nn[i] = scanner.nextInt();
}
Arrays.sort(nn);
int min = nn[1] - nn[0];
for (int i = 0; i < n-1; i++) {
if (nn[i+1]-nn[i]<min){
min = nn[i+1]-nn[i];
}
}
System.out.println(min);
}
}