import java.util.Scanner;
class Main {
	public static void main(String[] args){
		final int Number=100;
		try(Scanner sc = new Scanner(System.in)){
			int N = Integer.parseInt(sc.next());
			int[] p=new int[N];
			for(int i=0;i<N;i++) p[i] = Integer.parseInt(sc.next());
			int max=p[1];
			int min=p[0];
			int diff=p[1]-p[0];
			for(int i=1;i<N;i++){
				boolean renew=false;
				if(min>p[i]){
					min=p[i];
					max=p[i];
					renew=true;
				}
				if(max<p[i])max=p[i];
				if(!renew){
					diff=Math.max(diff, max-min);
				}else{
					diff=Math.max(diff, p[i]-p[i-1]);
				}
			}
			
			System.out.println(diff);
		}
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args){
		final int Number=100;
		try(Scanner sc = new Scanner(System.in)){
			int N = Integer.parseInt(sc.next());
			int[] p=new int[N];
			for(int i=0;i<N;i++) p[i] = Integer.parseInt(sc.next());
			int max=p[1];
			int min=p[0];
			int diff=p[1]-p[0];
			for(int i=1;i<N;i++){
				boolean renew=false;
				if(min>p[i]){
					min=p[i];
					max=p[i];
					renew=true;
				}
				if(max<p[i])max=p[i];
				if(!renew){
					diff=Math.max(diff, max-min);
				}else{
					diff=Math.max(diff, p[i]-p[i-1]);
				}
			}
			
			System.out.println(diff);
		}
	}
} Main public static void main(String[] args){
		final int Number=100;
		try(Scanner sc = new Scanner(System.in)){
			int N = Integer.parseInt(sc.next());
			int[] p=new int[N];
			for(int i=0;i<N;i++) p[i] = Integer.parseInt(sc.next());
			int max=p[1];
			int min=p[0];
			int diff=p[1]-p[0];
			for(int i=1;i<N;i++){
				boolean renew=false;
				if(min>p[i]){
					min=p[i];
					max=p[i];
					renew=true;
				}
				if(max<p[i])max=p[i];
				if(!renew){
					diff=Math.max(diff, max-min);
				}else{
					diff=Math.max(diff, p[i]-p[i-1]);
				}
			}
			
			System.out.println(diff);
		}
	} main {
		final int Number=100;
		try(Scanner sc = new Scanner(System.in)){
			int N = Integer.parseInt(sc.next());
			int[] p=new int[N];
			for(int i=0;i<N;i++) p[i] = Integer.parseInt(sc.next());
			int max=p[1];
			int min=p[0];
			int diff=p[1]-p[0];
			for(int i=1;i<N;i++){
				boolean renew=false;
				if(min>p[i]){
					min=p[i];
					max=p[i];
					renew=true;
				}
				if(max<p[i])max=p[i];
				if(!renew){
					diff=Math.max(diff, max-min);
				}else{
					diff=Math.max(diff, p[i]-p[i-1]);
				}
			}
			
			System.out.println(diff);
		}
	} final int Number=100; Number 100 try(Scanner sc = new Scanner(System.in)){
			int N = Integer.parseInt(sc.next());
			int[] p=new int[N];
			for(int i=0;i<N;i++) p[i] = Integer.parseInt(sc.next());
			int max=p[1];
			int min=p[0];
			int diff=p[1]-p[0];
			for(int i=1;i<N;i++){
				boolean renew=false;
				if(min>p[i]){
					min=p[i];
					max=p[i];
					renew=true;
				}
				if(max<p[i])max=p[i];
				if(!renew){
					diff=Math.max(diff, max-min);
				}else{
					diff=Math.max(diff, p[i]-p[i-1]);
				}
			}
			
			System.out.println(diff);
		} {
			int N = Integer.parseInt(sc.next());
			int[] p=new int[N];
			for(int i=0;i<N;i++) p[i] = Integer.parseInt(sc.next());
			int max=p[1];
			int min=p[0];
			int diff=p[1]-p[0];
			for(int i=1;i<N;i++){
				boolean renew=false;
				if(min>p[i]){
					min=p[i];
					max=p[i];
					renew=true;
				}
				if(max<p[i])max=p[i];
				if(!renew){
					diff=Math.max(diff, max-min);
				}else{
					diff=Math.max(diff, p[i]-p[i-1]);
				}
			}
			
			System.out.println(diff);
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] p=new int[N]; p new int[N] N for(int i=0;i<N;i++) p[i] = Integer.parseInt(sc.next()); int i=0; int i=0; i 0 i<N i N i++ i++ i p[i] = Integer.parseInt(sc.next()); p[i] = Integer.parseInt(sc.next()) p[i] p i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int max=p[1]; max p[1] p 1 int min=p[0]; min p[0] p 0 int diff=p[1]-p[0]; diff p[1]-p[0] p[1] p 1 p[0] p 0 for(int i=1;i<N;i++){
				boolean renew=false;
				if(min>p[i]){
					min=p[i];
					max=p[i];
					renew=true;
				}
				if(max<p[i])max=p[i];
				if(!renew){
					diff=Math.max(diff, max-min);
				}else{
					diff=Math.max(diff, p[i]-p[i-1]);
				}
			} int i=1; int i=1; i 1 i<N i N i++ i++ i {
				boolean renew=false;
				if(min>p[i]){
					min=p[i];
					max=p[i];
					renew=true;
				}
				if(max<p[i])max=p[i];
				if(!renew){
					diff=Math.max(diff, max-min);
				}else{
					diff=Math.max(diff, p[i]-p[i-1]);
				}
			} {
				boolean renew=false;
				if(min>p[i]){
					min=p[i];
					max=p[i];
					renew=true;
				}
				if(max<p[i])max=p[i];
				if(!renew){
					diff=Math.max(diff, max-min);
				}else{
					diff=Math.max(diff, p[i]-p[i-1]);
				}
			} boolean renew=false; renew false if(min>p[i]){
					min=p[i];
					max=p[i];
					renew=true;
				} min>p[i] min p[i] p i {
					min=p[i];
					max=p[i];
					renew=true;
				} min=p[i] min p[i] p i max=p[i] max p[i] p i renew=true renew true if(max<p[i])max=p[i]; max<p[i] max p[i] p i max=p[i] max p[i] p i if(!renew){
					diff=Math.max(diff, max-min);
				}else{
					diff=Math.max(diff, p[i]-p[i-1]);
				} !renew renew {
					diff=Math.max(diff, max-min);
				} diff=Math.max(diff, max-min) diff Math.max(diff, max-min) Math.max Math diff max-min max min {
					diff=Math.max(diff, p[i]-p[i-1]);
				} diff=Math.max(diff, p[i]-p[i-1]) diff Math.max(diff, p[i]-p[i-1]) Math.max Math diff p[i]-p[i-1] p[i] p i p[i-1] p i-1 i 1 System.out.println(diff) System.out.println System.out System System.out diff String[] args args
import java.util.Scanner;
class Main {
	public static void main(String[] args){
		final int Number=100;
		try(Scanner sc = new Scanner(System.in)){
			int N = Integer.parseInt(sc.next());
			int[] p=new int[N];
			for(int i=0;i<N;i++) p[i] = Integer.parseInt(sc.next());
			int max=p[1];
			int min=p[0];
			int diff=p[1]-p[0];
			for(int i=1;i<N;i++){
				boolean renew=false;
				if(min>p[i]){
					min=p[i];
					max=p[i];
					renew=true;
				}
				if(max<p[i])max=p[i];
				if(!renew){
					diff=Math.max(diff, max-min);
				}else{
					diff=Math.max(diff, p[i]-p[i-1]);
				}
			}
			
			System.out.println(diff);
		}
	}
}