import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		try {
			int lim = Integer.parseInt(in.readLine());
			
			int[] a = new int[lim];
			for (int i = 0; i < lim; i++) {
				a[i] = Integer.parseInt(in.readLine());
			}

			int max = -1000000000;
			int mini = a[0];
			for (int i = 0; i < lim; i++) {
				if (mini < a[i]) continue;
				else mini = a[i];
				for (int j = (i + 1); j < lim; j++) {
					int tmp = a[j] - a[i];
					if (max < tmp) max = tmp;
				}
			}
			System.out.println(max);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		try {
			int lim = Integer.parseInt(in.readLine());
			
			int[] a = new int[lim];
			for (int i = 0; i < lim; i++) {
				a[i] = Integer.parseInt(in.readLine());
			}

			int max = -1000000000;
			int mini = a[0];
			for (int i = 0; i < lim; i++) {
				if (mini < a[i]) continue;
				else mini = a[i];
				for (int j = (i + 1); j < lim; j++) {
					int tmp = a[j] - a[i];
					if (max < tmp) max = tmp;
				}
			}
			System.out.println(max);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} Main public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		try {
			int lim = Integer.parseInt(in.readLine());
			
			int[] a = new int[lim];
			for (int i = 0; i < lim; i++) {
				a[i] = Integer.parseInt(in.readLine());
			}

			int max = -1000000000;
			int mini = a[0];
			for (int i = 0; i < lim; i++) {
				if (mini < a[i]) continue;
				else mini = a[i];
				for (int j = (i + 1); j < lim; j++) {
					int tmp = a[j] - a[i];
					if (max < tmp) max = tmp;
				}
			}
			System.out.println(max);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} main {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		try {
			int lim = Integer.parseInt(in.readLine());
			
			int[] a = new int[lim];
			for (int i = 0; i < lim; i++) {
				a[i] = Integer.parseInt(in.readLine());
			}

			int max = -1000000000;
			int mini = a[0];
			for (int i = 0; i < lim; i++) {
				if (mini < a[i]) continue;
				else mini = a[i];
				for (int j = (i + 1); j < lim; j++) {
					int tmp = a[j] - a[i];
					if (max < tmp) max = tmp;
				}
			}
			System.out.println(max);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) try {
			int lim = Integer.parseInt(in.readLine());
			
			int[] a = new int[lim];
			for (int i = 0; i < lim; i++) {
				a[i] = Integer.parseInt(in.readLine());
			}

			int max = -1000000000;
			int mini = a[0];
			for (int i = 0; i < lim; i++) {
				if (mini < a[i]) continue;
				else mini = a[i];
				for (int j = (i + 1); j < lim; j++) {
					int tmp = a[j] - a[i];
					if (max < tmp) max = tmp;
				}
			}
			System.out.println(max);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} NumberFormatException e {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} IOException e {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			int lim = Integer.parseInt(in.readLine());
			
			int[] a = new int[lim];
			for (int i = 0; i < lim; i++) {
				a[i] = Integer.parseInt(in.readLine());
			}

			int max = -1000000000;
			int mini = a[0];
			for (int i = 0; i < lim; i++) {
				if (mini < a[i]) continue;
				else mini = a[i];
				for (int j = (i + 1); j < lim; j++) {
					int tmp = a[j] - a[i];
					if (max < tmp) max = tmp;
				}
			}
			System.out.println(max);
		} int lim = Integer.parseInt(in.readLine()); lim Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in int[] a = new int[lim]; a new int[lim] lim for (int i = 0; i < lim; i++) {
				a[i] = Integer.parseInt(in.readLine());
			} int i = 0; int i = 0; i 0 i < lim i lim i++ i++ i {
				a[i] = Integer.parseInt(in.readLine());
			} {
				a[i] = Integer.parseInt(in.readLine());
			} a[i] = Integer.parseInt(in.readLine()) a[i] a i Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in int max = -1000000000; max -1000000000 1000000000 int mini = a[0]; mini a[0] a 0 for (int i = 0; i < lim; i++) {
				if (mini < a[i]) continue;
				else mini = a[i];
				for (int j = (i + 1); j < lim; j++) {
					int tmp = a[j] - a[i];
					if (max < tmp) max = tmp;
				}
			} int i = 0; int i = 0; i 0 i < lim i lim i++ i++ i {
				if (mini < a[i]) continue;
				else mini = a[i];
				for (int j = (i + 1); j < lim; j++) {
					int tmp = a[j] - a[i];
					if (max < tmp) max = tmp;
				}
			} {
				if (mini < a[i]) continue;
				else mini = a[i];
				for (int j = (i + 1); j < lim; j++) {
					int tmp = a[j] - a[i];
					if (max < tmp) max = tmp;
				}
			} if (mini < a[i]) continue;
				else mini = a[i]; mini < a[i] mini a[i] a i continue; mini = a[i] mini a[i] a i for (int j = (i + 1); j < lim; j++) {
					int tmp = a[j] - a[i];
					if (max < tmp) max = tmp;
				} int j = (i + 1); int j = (i + 1); j (i + 1) i 1 j < lim j lim j++ j++ j {
					int tmp = a[j] - a[i];
					if (max < tmp) max = tmp;
				} {
					int tmp = a[j] - a[i];
					if (max < tmp) max = tmp;
				} int tmp = a[j] - a[i]; tmp a[j] - a[i] a[j] a j a[i] a i if (max < tmp) max = tmp; max < tmp max tmp max = tmp max tmp System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		try {
			int lim = Integer.parseInt(in.readLine());
			
			int[] a = new int[lim];
			for (int i = 0; i < lim; i++) {
				a[i] = Integer.parseInt(in.readLine());
			}

			int max = -1000000000;
			int mini = a[0];
			for (int i = 0; i < lim; i++) {
				if (mini < a[i]) continue;
				else mini = a[i];
				for (int j = (i + 1); j < lim; j++) {
					int tmp = a[j] - a[i];
					if (max < tmp) max = tmp;
				}
			}
			System.out.println(max);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		try {
			int lim = Integer.parseInt(in.readLine());
			
			int[] a = new int[lim];
			for (int i = 0; i < lim; i++) {
				a[i] = Integer.parseInt(in.readLine());
			}

			int max = -1000000000;
			int mini = a[0];
			for (int i = 0; i < lim; i++) {
				if (mini < a[i]) continue;
				else mini = a[i];
				for (int j = (i + 1); j < lim; j++) {
					int tmp = a[j] - a[i];
					if (max < tmp) max = tmp;
				}
			}
			System.out.println(max);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		try {
			int lim = Integer.parseInt(in.readLine());
			
			int[] a = new int[lim];
			for (int i = 0; i < lim; i++) {
				a[i] = Integer.parseInt(in.readLine());
			}

			int max = -1000000000;
			int mini = a[0];
			for (int i = 0; i < lim; i++) {
				if (mini < a[i]) continue;
				else mini = a[i];
				for (int j = (i + 1); j < lim; j++) {
					int tmp = a[j] - a[i];
					if (max < tmp) max = tmp;
				}
			}
			System.out.println(max);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}