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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine());

		long[] arr = new long[N];
		for (int i = 0; i < N; i++) {
			arr[i] = Long.parseLong(br.readLine());
		}

		long result = Long.MIN_VALUE;
		long min = Long.MAX_VALUE;
		for (int i = 0; i < N; i++) {
			if (arr[i] > min)
				continue;
			
			min = arr[i];
	
			for (int j = i + 1; j < N; j++) {
				if (arr[j] - arr[i] > result)
					result = arr[j] - arr[i];
			}
		}

		System.out.println(result);

		if (br != null) {
			br.close();
			br = null;
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine());

		long[] arr = new long[N];
		for (int i = 0; i < N; i++) {
			arr[i] = Long.parseLong(br.readLine());
		}

		long result = Long.MIN_VALUE;
		long min = Long.MAX_VALUE;
		for (int i = 0; i < N; i++) {
			if (arr[i] > min)
				continue;
			
			min = arr[i];
	
			for (int j = i + 1; j < N; j++) {
				if (arr[j] - arr[i] > result)
					result = arr[j] - arr[i];
			}
		}

		System.out.println(result);

		if (br != null) {
			br.close();
			br = null;
		}
	}
} Main public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine());

		long[] arr = new long[N];
		for (int i = 0; i < N; i++) {
			arr[i] = Long.parseLong(br.readLine());
		}

		long result = Long.MIN_VALUE;
		long min = Long.MAX_VALUE;
		for (int i = 0; i < N; i++) {
			if (arr[i] > min)
				continue;
			
			min = arr[i];
	
			for (int j = i + 1; j < N; j++) {
				if (arr[j] - arr[i] > result)
					result = arr[j] - arr[i];
			}
		}

		System.out.println(result);

		if (br != null) {
			br.close();
			br = null;
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine());

		long[] arr = new long[N];
		for (int i = 0; i < N; i++) {
			arr[i] = Long.parseLong(br.readLine());
		}

		long result = Long.MIN_VALUE;
		long min = Long.MAX_VALUE;
		for (int i = 0; i < N; i++) {
			if (arr[i] > min)
				continue;
			
			min = arr[i];
	
			for (int j = i + 1; j < N; j++) {
				if (arr[j] - arr[i] > result)
					result = arr[j] - arr[i];
			}
		}

		System.out.println(result);

		if (br != null) {
			br.close();
			br = null;
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int N = Integer.parseInt(br.readLine()); N Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br long[] arr = new long[N]; arr new long[N] N for (int i = 0; i < N; i++) {
			arr[i] = Long.parseLong(br.readLine());
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			arr[i] = Long.parseLong(br.readLine());
		} {
			arr[i] = Long.parseLong(br.readLine());
		} arr[i] = Long.parseLong(br.readLine()) arr[i] arr i Long.parseLong(br.readLine()) Long.parseLong Long br.readLine() br.readLine br long result = Long.MIN_VALUE; result Long.MIN_VALUE Long Long.MIN_VALUE long min = Long.MAX_VALUE; min Long.MAX_VALUE Long Long.MAX_VALUE for (int i = 0; i < N; i++) {
			if (arr[i] > min)
				continue;
			
			min = arr[i];
	
			for (int j = i + 1; j < N; j++) {
				if (arr[j] - arr[i] > result)
					result = arr[j] - arr[i];
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			if (arr[i] > min)
				continue;
			
			min = arr[i];
	
			for (int j = i + 1; j < N; j++) {
				if (arr[j] - arr[i] > result)
					result = arr[j] - arr[i];
			}
		} {
			if (arr[i] > min)
				continue;
			
			min = arr[i];
	
			for (int j = i + 1; j < N; j++) {
				if (arr[j] - arr[i] > result)
					result = arr[j] - arr[i];
			}
		} if (arr[i] > min)
				continue; arr[i] > min arr[i] arr i min continue; min = arr[i] min arr[i] arr i for (int j = i + 1; j < N; j++) {
				if (arr[j] - arr[i] > result)
					result = arr[j] - arr[i];
			} int j = i + 1; int j = i + 1; j i + 1 i 1 j < N j N j++ j++ j {
				if (arr[j] - arr[i] > result)
					result = arr[j] - arr[i];
			} {
				if (arr[j] - arr[i] > result)
					result = arr[j] - arr[i];
			} if (arr[j] - arr[i] > result)
					result = arr[j] - arr[i]; arr[j] - arr[i] > result arr[j] - arr[i] arr[j] arr j arr[i] arr i result result = arr[j] - arr[i] result arr[j] - arr[i] arr[j] arr j arr[i] arr i System.out.println(result) System.out.println System.out System System.out result if (br != null) {
			br.close();
			br = null;
		} br != null br null {
			br.close();
			br = null;
		} br.close() br.close br br = null br null String[] args args public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine());

		long[] arr = new long[N];
		for (int i = 0; i < N; i++) {
			arr[i] = Long.parseLong(br.readLine());
		}

		long result = Long.MIN_VALUE;
		long min = Long.MAX_VALUE;
		for (int i = 0; i < N; i++) {
			if (arr[i] > min)
				continue;
			
			min = arr[i];
	
			for (int j = i + 1; j < N; j++) {
				if (arr[j] - arr[i] > result)
					result = arr[j] - arr[i];
			}
		}

		System.out.println(result);

		if (br != null) {
			br.close();
			br = null;
		}
	}
} public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine());

		long[] arr = new long[N];
		for (int i = 0; i < N; i++) {
			arr[i] = Long.parseLong(br.readLine());
		}

		long result = Long.MIN_VALUE;
		long min = Long.MAX_VALUE;
		for (int i = 0; i < N; i++) {
			if (arr[i] > min)
				continue;
			
			min = arr[i];
	
			for (int j = i + 1; j < N; j++) {
				if (arr[j] - arr[i] > result)
					result = arr[j] - arr[i];
			}
		}

		System.out.println(result);

		if (br != null) {
			br.close();
			br = null;
		}
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine());

		long[] arr = new long[N];
		for (int i = 0; i < N; i++) {
			arr[i] = Long.parseLong(br.readLine());
		}

		long result = Long.MIN_VALUE;
		long min = Long.MAX_VALUE;
		for (int i = 0; i < N; i++) {
			if (arr[i] > min)
				continue;
			
			min = arr[i];
	
			for (int j = i + 1; j < N; j++) {
				if (arr[j] - arr[i] > result)
					result = arr[j] - arr[i];
			}
		}

		System.out.println(result);

		if (br != null) {
			br.close();
			br = null;
		}
	}
}