import java.util.Scanner; class N021{ public static void main(String args[]){ Scanner s = new Scanner(System.in); int n = s.nextInt(); int k = s.nextInt(); int max = 0; int min = 1000; int a[] = new int[n]; for(int i = 0; i < n; i++){ a[i] = s.nextInt(); max = Math.max(max, a[i]); min = Math.min(min, a[i]); } System.out.println(max - min); } }