import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		int i, max = -2147483646, currentmin, size, differ;
		List<Integer> numbers = new ArrayList<Integer>();

		Scanner in = new Scanner(System.in);
		
		size = Integer.parseInt(in.nextLine());
		for(i = 0; i < size; i++) numbers.add(Integer.parseInt(in.nextLine()));
		
		currentmin = numbers.get(0);
		for(i = 1; i < size; i++){
			differ = numbers.get(i) - currentmin;
			if(numbers.get(i) < currentmin) currentmin = numbers.get(i);
			if(differ > max) max = differ;
		}
		System.out.println(max);

	}
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.lang.Math; Math java.lang public class Main {
	public static void main(String[] args){
		int i, max = -2147483646, currentmin, size, differ;
		List<Integer> numbers = new ArrayList<Integer>();

		Scanner in = new Scanner(System.in);
		
		size = Integer.parseInt(in.nextLine());
		for(i = 0; i < size; i++) numbers.add(Integer.parseInt(in.nextLine()));
		
		currentmin = numbers.get(0);
		for(i = 1; i < size; i++){
			differ = numbers.get(i) - currentmin;
			if(numbers.get(i) < currentmin) currentmin = numbers.get(i);
			if(differ > max) max = differ;
		}
		System.out.println(max);

	}
} Main public static void main(String[] args){
		int i, max = -2147483646, currentmin, size, differ;
		List<Integer> numbers = new ArrayList<Integer>();

		Scanner in = new Scanner(System.in);
		
		size = Integer.parseInt(in.nextLine());
		for(i = 0; i < size; i++) numbers.add(Integer.parseInt(in.nextLine()));
		
		currentmin = numbers.get(0);
		for(i = 1; i < size; i++){
			differ = numbers.get(i) - currentmin;
			if(numbers.get(i) < currentmin) currentmin = numbers.get(i);
			if(differ > max) max = differ;
		}
		System.out.println(max);

	} main {
		int i, max = -2147483646, currentmin, size, differ;
		List<Integer> numbers = new ArrayList<Integer>();

		Scanner in = new Scanner(System.in);
		
		size = Integer.parseInt(in.nextLine());
		for(i = 0; i < size; i++) numbers.add(Integer.parseInt(in.nextLine()));
		
		currentmin = numbers.get(0);
		for(i = 1; i < size; i++){
			differ = numbers.get(i) - currentmin;
			if(numbers.get(i) < currentmin) currentmin = numbers.get(i);
			if(differ > max) max = differ;
		}
		System.out.println(max);

	} int i i max = -2147483646 max -2147483646 2147483646 currentmin currentmin size size differ; differ List<Integer> numbers = new ArrayList<Integer>(); numbers new ArrayList<Integer>() Scanner in = new Scanner(System.in); in new Scanner(System.in) size = Integer.parseInt(in.nextLine()) size Integer.parseInt(in.nextLine()) Integer.parseInt Integer in.nextLine() in.nextLine in for(i = 0; i < size; i++) numbers.add(Integer.parseInt(in.nextLine())); i = 0; i = 0 i 0 i < size i size i++ i++ i numbers.add(Integer.parseInt(in.nextLine())); numbers.add(Integer.parseInt(in.nextLine())) numbers.add numbers Integer.parseInt(in.nextLine()) Integer.parseInt Integer in.nextLine() in.nextLine in currentmin = numbers.get(0) currentmin numbers.get(0) numbers.get numbers 0 for(i = 1; i < size; i++){
			differ = numbers.get(i) - currentmin;
			if(numbers.get(i) < currentmin) currentmin = numbers.get(i);
			if(differ > max) max = differ;
		} i = 1; i = 1 i 1 i < size i size i++ i++ i {
			differ = numbers.get(i) - currentmin;
			if(numbers.get(i) < currentmin) currentmin = numbers.get(i);
			if(differ > max) max = differ;
		} {
			differ = numbers.get(i) - currentmin;
			if(numbers.get(i) < currentmin) currentmin = numbers.get(i);
			if(differ > max) max = differ;
		} differ = numbers.get(i) - currentmin differ numbers.get(i) - currentmin numbers.get(i) numbers.get numbers i currentmin if(numbers.get(i) < currentmin) currentmin = numbers.get(i); numbers.get(i) < currentmin numbers.get(i) numbers.get numbers i currentmin currentmin = numbers.get(i) currentmin numbers.get(i) numbers.get numbers i if(differ > max) max = differ; differ > max differ max max = differ max differ 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){
		int i, max = -2147483646, currentmin, size, differ;
		List<Integer> numbers = new ArrayList<Integer>();

		Scanner in = new Scanner(System.in);
		
		size = Integer.parseInt(in.nextLine());
		for(i = 0; i < size; i++) numbers.add(Integer.parseInt(in.nextLine()));
		
		currentmin = numbers.get(0);
		for(i = 1; i < size; i++){
			differ = numbers.get(i) - currentmin;
			if(numbers.get(i) < currentmin) currentmin = numbers.get(i);
			if(differ > max) max = differ;
		}
		System.out.println(max);

	}
} public class Main {
	public static void main(String[] args){
		int i, max = -2147483646, currentmin, size, differ;
		List<Integer> numbers = new ArrayList<Integer>();

		Scanner in = new Scanner(System.in);
		
		size = Integer.parseInt(in.nextLine());
		for(i = 0; i < size; i++) numbers.add(Integer.parseInt(in.nextLine()));
		
		currentmin = numbers.get(0);
		for(i = 1; i < size; i++){
			differ = numbers.get(i) - currentmin;
			if(numbers.get(i) < currentmin) currentmin = numbers.get(i);
			if(differ > max) max = differ;
		}
		System.out.println(max);

	}
} Main
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		int i, max = -2147483646, currentmin, size, differ;
		List<Integer> numbers = new ArrayList<Integer>();

		Scanner in = new Scanner(System.in);
		
		size = Integer.parseInt(in.nextLine());
		for(i = 0; i < size; i++) numbers.add(Integer.parseInt(in.nextLine()));
		
		currentmin = numbers.get(0);
		for(i = 1; i < size; i++){
			differ = numbers.get(i) - currentmin;
			if(numbers.get(i) < currentmin) currentmin = numbers.get(i);
			if(differ > max) max = differ;
		}
		System.out.println(max);

	}
}