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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(in.nextInt());
		}
		int minv = list.get(0);
		int maxv = list.get(1) - list.get(0);
		for (int i = 1; i < n; i++) {
			maxv = max(maxv,minv,list.get(i));
			minv = min(minv,list.get(i));
		}
		System.out.println(maxv);
	}
	static int max(int maxv, int minv, int r){
		if(maxv > (r -minv) ){
			return maxv;
		}else{
			return r -minv;
		}
	}
	static int min(int minv, int r){
		if(minv > r){
			return r;
		}else{
			return minv;
		}
	}
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(in.nextInt());
		}
		int minv = list.get(0);
		int maxv = list.get(1) - list.get(0);
		for (int i = 1; i < n; i++) {
			maxv = max(maxv,minv,list.get(i));
			minv = min(minv,list.get(i));
		}
		System.out.println(maxv);
	}
	static int max(int maxv, int minv, int r){
		if(maxv > (r -minv) ){
			return maxv;
		}else{
			return r -minv;
		}
	}
	static int min(int minv, int r){
		if(minv > r){
			return r;
		}else{
			return minv;
		}
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(in.nextInt());
		}
		int minv = list.get(0);
		int maxv = list.get(1) - list.get(0);
		for (int i = 1; i < n; i++) {
			maxv = max(maxv,minv,list.get(i));
			minv = min(minv,list.get(i));
		}
		System.out.println(maxv);
	} main {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(in.nextInt());
		}
		int minv = list.get(0);
		int maxv = list.get(1) - list.get(0);
		for (int i = 1; i < n; i++) {
			maxv = max(maxv,minv,list.get(i));
			minv = min(minv,list.get(i));
		}
		System.out.println(maxv);
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int n = in.nextInt(); n in.nextInt() in.nextInt in List<Integer> list = new ArrayList<>(); list new ArrayList<>() for (int i = 0; i < n; i++) {
			list.add(in.nextInt());
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			list.add(in.nextInt());
		} {
			list.add(in.nextInt());
		} list.add(in.nextInt()) list.add list in.nextInt() in.nextInt in int minv = list.get(0); minv list.get(0) list.get list 0 int maxv = list.get(1) - list.get(0); maxv list.get(1) - list.get(0) list.get(1) list.get list 1 list.get(0) list.get list 0 for (int i = 1; i < n; i++) {
			maxv = max(maxv,minv,list.get(i));
			minv = min(minv,list.get(i));
		} int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
			maxv = max(maxv,minv,list.get(i));
			minv = min(minv,list.get(i));
		} {
			maxv = max(maxv,minv,list.get(i));
			minv = min(minv,list.get(i));
		} maxv = max(maxv,minv,list.get(i)) maxv max(maxv,minv,list.get(i)) max maxv minv list.get(i) list.get list i minv = min(minv,list.get(i)) minv min(minv,list.get(i)) min minv list.get(i) list.get list i System.out.println(maxv) System.out.println System.out System System.out maxv String[] args args static int max(int maxv, int minv, int r){
		if(maxv > (r -minv) ){
			return maxv;
		}else{
			return r -minv;
		}
	} max {
		if(maxv > (r -minv) ){
			return maxv;
		}else{
			return r -minv;
		}
	} if(maxv > (r -minv) ){
			return maxv;
		}else{
			return r -minv;
		} maxv > (r -minv) maxv (r -minv) r minv {
			return maxv;
		} return maxv; maxv {
			return r -minv;
		} return r -minv; r -minv r minv int maxv maxv int minv minv int r r static int min(int minv, int r){
		if(minv > r){
			return r;
		}else{
			return minv;
		}
	} min {
		if(minv > r){
			return r;
		}else{
			return minv;
		}
	} if(minv > r){
			return r;
		}else{
			return minv;
		} minv > r minv r {
			return r;
		} return r; r {
			return minv;
		} return minv; minv int minv minv int r r public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(in.nextInt());
		}
		int minv = list.get(0);
		int maxv = list.get(1) - list.get(0);
		for (int i = 1; i < n; i++) {
			maxv = max(maxv,minv,list.get(i));
			minv = min(minv,list.get(i));
		}
		System.out.println(maxv);
	}
	static int max(int maxv, int minv, int r){
		if(maxv > (r -minv) ){
			return maxv;
		}else{
			return r -minv;
		}
	}
	static int min(int minv, int r){
		if(minv > r){
			return r;
		}else{
			return minv;
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(in.nextInt());
		}
		int minv = list.get(0);
		int maxv = list.get(1) - list.get(0);
		for (int i = 1; i < n; i++) {
			maxv = max(maxv,minv,list.get(i));
			minv = min(minv,list.get(i));
		}
		System.out.println(maxv);
	}
	static int max(int maxv, int minv, int r){
		if(maxv > (r -minv) ){
			return maxv;
		}else{
			return r -minv;
		}
	}
	static int min(int minv, int r){
		if(minv > r){
			return r;
		}else{
			return minv;
		}
	}
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(in.nextInt());
		}
		int minv = list.get(0);
		int maxv = list.get(1) - list.get(0);
		for (int i = 1; i < n; i++) {
			maxv = max(maxv,minv,list.get(i));
			minv = min(minv,list.get(i));
		}
		System.out.println(maxv);
	}
	static int max(int maxv, int minv, int r){
		if(maxv > (r -minv) ){
			return maxv;
		}else{
			return r -minv;
		}
	}
	static int min(int minv, int r){
		if(minv > r){
			return r;
		}else{
			return minv;
		}
	}
}