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(); TreeMap nums = new TreeMap(); boolean done = false; for(int a_i=0; a_i < n; a_i++){ int nextVal = in.nextInt(); if(nums.containsKey(nextVal)) { System.out.println(0); done = true; break; } nums.put(nextVal, 0); } if(!done) { Set keyset = nums.keySet(); Integer[] keys = keyset.toArray(new Integer[0]); int minDiff = keys[1] - keys[0]; //minDiff = minDiff < 0 ? -minDiff : minDiff; for(int i = 2; i < keys.length; i++) { int diff = keys[i] - keys[i - 1]; //diff = diff < 0 ? -diff : diff; if(diff < minDiff) minDiff = diff; if(minDiff == 0) break; } System.out.println(minDiff); } } }