import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	static String a;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] list = new int[n];
		for(int i = 0; i < n; i++) {
			list[i] = stdIn.nextInt();
		}
		int max = Integer.MIN_VALUE;
		int pre = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++) {
			if(pre <= list[i]) continue;
			else pre = list[i];
			for(int j = i+1; j < n; j++) {
				if(list[j] - list[i] > max) {
					max = list[j] - list[i];
				}
			}
		}
		System.out.println(max);
	}
} import java.io.*; io.* java import java.util.ArrayDeque; ArrayDeque java.util import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.Comparator; Comparator java.util import java.util.Scanner; Scanner java.util public class Main {
	static String a;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] list = new int[n];
		for(int i = 0; i < n; i++) {
			list[i] = stdIn.nextInt();
		}
		int max = Integer.MIN_VALUE;
		int pre = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++) {
			if(pre <= list[i]) continue;
			else pre = list[i];
			for(int j = i+1; j < n; j++) {
				if(list[j] - list[i] > max) {
					max = list[j] - list[i];
				}
			}
		}
		System.out.println(max);
	}
} Main static String a; a public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] list = new int[n];
		for(int i = 0; i < n; i++) {
			list[i] = stdIn.nextInt();
		}
		int max = Integer.MIN_VALUE;
		int pre = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++) {
			if(pre <= list[i]) continue;
			else pre = list[i];
			for(int j = i+1; j < n; j++) {
				if(list[j] - list[i] > max) {
					max = list[j] - list[i];
				}
			}
		}
		System.out.println(max);
	} main {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] list = new int[n];
		for(int i = 0; i < n; i++) {
			list[i] = stdIn.nextInt();
		}
		int max = Integer.MIN_VALUE;
		int pre = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++) {
			if(pre <= list[i]) continue;
			else pre = list[i];
			for(int j = i+1; j < n; j++) {
				if(list[j] - list[i] > max) {
					max = list[j] - list[i];
				}
			}
		}
		System.out.println(max);
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int n = stdIn.nextInt(); n stdIn.nextInt() stdIn.nextInt stdIn int[] list = new int[n]; list new int[n] n for(int i = 0; i < n; i++) {
			list[i] = stdIn.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			list[i] = stdIn.nextInt();
		} {
			list[i] = stdIn.nextInt();
		} list[i] = stdIn.nextInt() list[i] list i stdIn.nextInt() stdIn.nextInt stdIn int max = Integer.MIN_VALUE; max Integer.MIN_VALUE Integer Integer.MIN_VALUE int pre = Integer.MAX_VALUE; pre Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i = 0; i < n; i++) {
			if(pre <= list[i]) continue;
			else pre = list[i];
			for(int j = i+1; j < n; j++) {
				if(list[j] - list[i] > max) {
					max = list[j] - list[i];
				}
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			if(pre <= list[i]) continue;
			else pre = list[i];
			for(int j = i+1; j < n; j++) {
				if(list[j] - list[i] > max) {
					max = list[j] - list[i];
				}
			}
		} {
			if(pre <= list[i]) continue;
			else pre = list[i];
			for(int j = i+1; j < n; j++) {
				if(list[j] - list[i] > max) {
					max = list[j] - list[i];
				}
			}
		} if(pre <= list[i]) continue;
			else pre = list[i]; pre <= list[i] pre list[i] list i continue; pre = list[i] pre list[i] list i for(int j = i+1; j < n; j++) {
				if(list[j] - list[i] > max) {
					max = list[j] - list[i];
				}
			} int j = i+1; int j = i+1; j i+1 i 1 j < n j n j++ j++ j {
				if(list[j] - list[i] > max) {
					max = list[j] - list[i];
				}
			} {
				if(list[j] - list[i] > max) {
					max = list[j] - list[i];
				}
			} if(list[j] - list[i] > max) {
					max = list[j] - list[i];
				} list[j] - list[i] > max list[j] - list[i] list[j] list j list[i] list i max {
					max = list[j] - list[i];
				} max = list[j] - list[i] max list[j] - list[i] list[j] list j list[i] list i System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main {
	static String a;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] list = new int[n];
		for(int i = 0; i < n; i++) {
			list[i] = stdIn.nextInt();
		}
		int max = Integer.MIN_VALUE;
		int pre = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++) {
			if(pre <= list[i]) continue;
			else pre = list[i];
			for(int j = i+1; j < n; j++) {
				if(list[j] - list[i] > max) {
					max = list[j] - list[i];
				}
			}
		}
		System.out.println(max);
	}
} public class Main {
	static String a;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] list = new int[n];
		for(int i = 0; i < n; i++) {
			list[i] = stdIn.nextInt();
		}
		int max = Integer.MIN_VALUE;
		int pre = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++) {
			if(pre <= list[i]) continue;
			else pre = list[i];
			for(int j = i+1; j < n; j++) {
				if(list[j] - list[i] > max) {
					max = list[j] - list[i];
				}
			}
		}
		System.out.println(max);
	}
} Main
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	static String a;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] list = new int[n];
		for(int i = 0; i < n; i++) {
			list[i] = stdIn.nextInt();
		}
		int max = Integer.MIN_VALUE;
		int pre = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++) {
			if(pre <= list[i]) continue;
			else pre = list[i];
			for(int j = i+1; j < n; j++) {
				if(list[j] - list[i] > max) {
					max = list[j] - list[i];
				}
			}
		}
		System.out.println(max);
	}
}