import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int d_set=sc.nextInt();
		int[] ary=new int[d_set];
		for(int i=0; i<d_set; i++) {
			ary[i]=sc.nextInt();
		}
		int min=114514810;
		int max=-114514810;
		int tmp1=0;
		int tmp2=0;
		for(int i=0; i<d_set; i++) {
			for(int j=i; j<d_set; j++) {
				if(ary[i]>ary[j]) {
					tmp1=ary[i];
					tmp2=ary[j];
					ary[i]=tmp2;
					ary[j]=tmp1;
				}
			}
		}
		System.out.println(Math.abs(ary[d_set-1]-ary[0]));
	}
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int d_set=sc.nextInt();
		int[] ary=new int[d_set];
		for(int i=0; i<d_set; i++) {
			ary[i]=sc.nextInt();
		}
		int min=114514810;
		int max=-114514810;
		int tmp1=0;
		int tmp2=0;
		for(int i=0; i<d_set; i++) {
			for(int j=i; j<d_set; j++) {
				if(ary[i]>ary[j]) {
					tmp1=ary[i];
					tmp2=ary[j];
					ary[i]=tmp2;
					ary[j]=tmp1;
				}
			}
		}
		System.out.println(Math.abs(ary[d_set-1]-ary[0]));
	}
} Main public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int d_set=sc.nextInt();
		int[] ary=new int[d_set];
		for(int i=0; i<d_set; i++) {
			ary[i]=sc.nextInt();
		}
		int min=114514810;
		int max=-114514810;
		int tmp1=0;
		int tmp2=0;
		for(int i=0; i<d_set; i++) {
			for(int j=i; j<d_set; j++) {
				if(ary[i]>ary[j]) {
					tmp1=ary[i];
					tmp2=ary[j];
					ary[i]=tmp2;
					ary[j]=tmp1;
				}
			}
		}
		System.out.println(Math.abs(ary[d_set-1]-ary[0]));
	} main {
		Scanner sc=new Scanner(System.in);
		int d_set=sc.nextInt();
		int[] ary=new int[d_set];
		for(int i=0; i<d_set; i++) {
			ary[i]=sc.nextInt();
		}
		int min=114514810;
		int max=-114514810;
		int tmp1=0;
		int tmp2=0;
		for(int i=0; i<d_set; i++) {
			for(int j=i; j<d_set; j++) {
				if(ary[i]>ary[j]) {
					tmp1=ary[i];
					tmp2=ary[j];
					ary[i]=tmp2;
					ary[j]=tmp1;
				}
			}
		}
		System.out.println(Math.abs(ary[d_set-1]-ary[0]));
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int d_set=sc.nextInt(); d_set sc.nextInt() sc.nextInt sc int[] ary=new int[d_set]; ary new int[d_set] d_set for(int i=0; i<d_set; i++) {
			ary[i]=sc.nextInt();
		} int i=0; int i=0; i 0 i<d_set i d_set i++ i++ i {
			ary[i]=sc.nextInt();
		} {
			ary[i]=sc.nextInt();
		} ary[i]=sc.nextInt() ary[i] ary i sc.nextInt() sc.nextInt sc int min=114514810; min 114514810 int max=-114514810; max -114514810 114514810 int tmp1=0; tmp1 0 int tmp2=0; tmp2 0 for(int i=0; i<d_set; i++) {
			for(int j=i; j<d_set; j++) {
				if(ary[i]>ary[j]) {
					tmp1=ary[i];
					tmp2=ary[j];
					ary[i]=tmp2;
					ary[j]=tmp1;
				}
			}
		} int i=0; int i=0; i 0 i<d_set i d_set i++ i++ i {
			for(int j=i; j<d_set; j++) {
				if(ary[i]>ary[j]) {
					tmp1=ary[i];
					tmp2=ary[j];
					ary[i]=tmp2;
					ary[j]=tmp1;
				}
			}
		} {
			for(int j=i; j<d_set; j++) {
				if(ary[i]>ary[j]) {
					tmp1=ary[i];
					tmp2=ary[j];
					ary[i]=tmp2;
					ary[j]=tmp1;
				}
			}
		} for(int j=i; j<d_set; j++) {
				if(ary[i]>ary[j]) {
					tmp1=ary[i];
					tmp2=ary[j];
					ary[i]=tmp2;
					ary[j]=tmp1;
				}
			} int j=i; int j=i; j i j<d_set j d_set j++ j++ j {
				if(ary[i]>ary[j]) {
					tmp1=ary[i];
					tmp2=ary[j];
					ary[i]=tmp2;
					ary[j]=tmp1;
				}
			} {
				if(ary[i]>ary[j]) {
					tmp1=ary[i];
					tmp2=ary[j];
					ary[i]=tmp2;
					ary[j]=tmp1;
				}
			} if(ary[i]>ary[j]) {
					tmp1=ary[i];
					tmp2=ary[j];
					ary[i]=tmp2;
					ary[j]=tmp1;
				} ary[i]>ary[j] ary[i] ary i ary[j] ary j {
					tmp1=ary[i];
					tmp2=ary[j];
					ary[i]=tmp2;
					ary[j]=tmp1;
				} tmp1=ary[i] tmp1 ary[i] ary i tmp2=ary[j] tmp2 ary[j] ary j ary[i]=tmp2 ary[i] ary i tmp2 ary[j]=tmp1 ary[j] ary j tmp1 System.out.println(Math.abs(ary[d_set-1]-ary[0])) System.out.println System.out System System.out Math.abs(ary[d_set-1]-ary[0]) Math.abs Math ary[d_set-1]-ary[0] ary[d_set-1] ary d_set-1 d_set 1 ary[0] ary 0 String[] args args
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int d_set=sc.nextInt();
		int[] ary=new int[d_set];
		for(int i=0; i<d_set; i++) {
			ary[i]=sc.nextInt();
		}
		int min=114514810;
		int max=-114514810;
		int tmp1=0;
		int tmp2=0;
		for(int i=0; i<d_set; i++) {
			for(int j=i; j<d_set; j++) {
				if(ary[i]>ary[j]) {
					tmp1=ary[i];
					tmp2=ary[j];
					ary[i]=tmp2;
					ary[j]=tmp1;
				}
			}
		}
		System.out.println(Math.abs(ary[d_set-1]-ary[0]));
	}
}