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) { try (Scanner in = new Scanner(System.in);) { int n = in.nextInt(); Long[] a = new Long[n]; for(int a_i=0; a_i < n; a_i++){ a[a_i] = in.nextLong(); } // sort the given array in ascending order on the absolute value of each element Arrays.sort(a, Comparator.comparingLong(Math::abs)); // since the array is sorted, the absolute difference of first two elements is the result System.out.println(Math.abs(a[0] - a[1])); } catch (Exception e) { e.printStackTrace(); } } }