import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int minv=sc.nextInt();
		int maxv=-1000000000;
		for(int j=1; j<n; j++){
			int x=sc.nextInt();
			maxv=max(maxv,x-minv);
			minv=min(minv,x);
		}
		System.out.println(maxv);
	}
	public static int max(int x,int y){
		if(x>y){
			return x;
		}else{
			return y;
		}
	}
	public static int min(int x,int y){
		if(x<y){
			return x;
		}else{
			return y;
		}
	}

	} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int minv=sc.nextInt();
		int maxv=-1000000000;
		for(int j=1; j<n; j++){
			int x=sc.nextInt();
			maxv=max(maxv,x-minv);
			minv=min(minv,x);
		}
		System.out.println(maxv);
	}
	public static int max(int x,int y){
		if(x>y){
			return x;
		}else{
			return y;
		}
	}
	public static int min(int x,int y){
		if(x<y){
			return x;
		}else{
			return y;
		}
	}

	} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int minv=sc.nextInt();
		int maxv=-1000000000;
		for(int j=1; j<n; j++){
			int x=sc.nextInt();
			maxv=max(maxv,x-minv);
			minv=min(minv,x);
		}
		System.out.println(maxv);
	} main {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int minv=sc.nextInt();
		int maxv=-1000000000;
		for(int j=1; j<n; j++){
			int x=sc.nextInt();
			maxv=max(maxv,x-minv);
			minv=min(minv,x);
		}
		System.out.println(maxv);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int minv=sc.nextInt(); minv sc.nextInt() sc.nextInt sc int maxv=-1000000000; maxv -1000000000 1000000000 for(int j=1; j<n; j++){
			int x=sc.nextInt();
			maxv=max(maxv,x-minv);
			minv=min(minv,x);
		} int j=1; int j=1; j 1 j<n j n j++ j++ j {
			int x=sc.nextInt();
			maxv=max(maxv,x-minv);
			minv=min(minv,x);
		} {
			int x=sc.nextInt();
			maxv=max(maxv,x-minv);
			minv=min(minv,x);
		} int x=sc.nextInt(); x sc.nextInt() sc.nextInt sc maxv=max(maxv,x-minv) maxv max(maxv,x-minv) max maxv x-minv x minv minv=min(minv,x) minv min(minv,x) min minv x System.out.println(maxv) System.out.println System.out System System.out maxv String[] args args public static int max(int x,int y){
		if(x>y){
			return x;
		}else{
			return y;
		}
	} max {
		if(x>y){
			return x;
		}else{
			return y;
		}
	} if(x>y){
			return x;
		}else{
			return y;
		} x>y x y {
			return x;
		} return x; x {
			return y;
		} return y; y int x x int y y public static int min(int x,int y){
		if(x<y){
			return x;
		}else{
			return y;
		}
	} min {
		if(x<y){
			return x;
		}else{
			return y;
		}
	} if(x<y){
			return x;
		}else{
			return y;
		} x<y x y {
			return x;
		} return x; x {
			return y;
		} return y; y int x x int y y public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int minv=sc.nextInt();
		int maxv=-1000000000;
		for(int j=1; j<n; j++){
			int x=sc.nextInt();
			maxv=max(maxv,x-minv);
			minv=min(minv,x);
		}
		System.out.println(maxv);
	}
	public static int max(int x,int y){
		if(x>y){
			return x;
		}else{
			return y;
		}
	}
	public static int min(int x,int y){
		if(x<y){
			return x;
		}else{
			return y;
		}
	}

	} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int minv=sc.nextInt();
		int maxv=-1000000000;
		for(int j=1; j<n; j++){
			int x=sc.nextInt();
			maxv=max(maxv,x-minv);
			minv=min(minv,x);
		}
		System.out.println(maxv);
	}
	public static int max(int x,int y){
		if(x>y){
			return x;
		}else{
			return y;
		}
	}
	public static int min(int x,int y){
		if(x<y){
			return x;
		}else{
			return y;
		}
	}

	} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int minv=sc.nextInt();
		int maxv=-1000000000;
		for(int j=1; j<n; j++){
			int x=sc.nextInt();
			maxv=max(maxv,x-minv);
			minv=min(minv,x);
		}
		System.out.println(maxv);
	}
	public static int max(int x,int y){
		if(x>y){
			return x;
		}else{
			return y;
		}
	}
	public static int min(int x,int y){
		if(x<y){
			return x;
		}else{
			return y;
		}
	}

	}
