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 int min1 = a[0]; int min2 = a[0]; int index1 = 0; for(int i = 0; i < n; i++){ if(a[i] < min1 & a[i] >= 0){ min1 = a[i]; index1 = i; } } for(int i = 0; i < n; i++){ if(a[i] < min1 & a[i] >= 0 & i != index1){ min2 = a[i]; } } int ans = Math.abs(min1 - min2); int ans2 = Math.abs(min2 - min1); if(ans < ans2){ System.out.println(ans); }else{ System.out.println(ans2); } } }