import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; public class No135{ public static void main(String[] args) { ArrayList list = new ArrayList(); try{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String n = br.readLine(); String[] str = br.readLine().split(" "); for(int i=0; i < str.length; i++) list.add(Integer.parseInt(str[i])); Collections.sort(list); System.out.println(getAns(list)); } catch(IOException e){ e.getStackTrace(); } catch(NumberFormatException e){ e.getStackTrace(); } } public static int getAns(ArrayList a){ int ans = 100000000; for(int i= 2; i< a.size(); i++){ if(a.get(i) == a.get(i-1)) continue; else if(ans > (a.get(i) - a.get(i-1))) ans = a.get(i) - a.get(i-1); } return ans; } }