import java.io.*; import java.util.*; import java.math.*; class Main135 { public static void out (Object out) { System.out.println(out); } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int ans = Integer.MAX_VALUE; int n = Integer.parseInt(br.readLine()); String[] line = br.readLine().split(" "); int[] nums = new int[n]; for (int i = 0; i < n; i++) { nums[i] = Integer.parseInt(line[i]); } Arrays.sort(nums); boolean flg = false; for (int i = 1; i < n; i++) { if (nums[i] == nums[i - 1]) continue; flg = true; ans = Math.min(ans , nums[i] - nums[i - 1]); } out(flg ? ans : 0); } }