
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] num = new int[n];
		for(int i=0;i<n;i++){
			num[i] = sc.nextInt();
		}	
		int max = -1000000000;
		int nowm = num[0];
		for(int i=1;i<n;i++){
			max = (int)Math.max(max, num[i] - nowm);
			nowm = (int)Math.min(nowm, num[i]);	
		}

		System.out.println(max);
	}
}

 import java.io.*; io.* java import java.util.*; util.* java class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] num = new int[n];
		for(int i=0;i<n;i++){
			num[i] = sc.nextInt();
		}	
		int max = -1000000000;
		int nowm = num[0];
		for(int i=1;i<n;i++){
			max = (int)Math.max(max, num[i] - nowm);
			nowm = (int)Math.min(nowm, num[i]);	
		}

		System.out.println(max);
	}
} Main public static void main(String[] args){
		solve();
	} main {
		solve();
	} solve() solve String[] args args public static void solve(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] num = new int[n];
		for(int i=0;i<n;i++){
			num[i] = sc.nextInt();
		}	
		int max = -1000000000;
		int nowm = num[0];
		for(int i=1;i<n;i++){
			max = (int)Math.max(max, num[i] - nowm);
			nowm = (int)Math.min(nowm, num[i]);	
		}

		System.out.println(max);
	} solve {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] num = new int[n];
		for(int i=0;i<n;i++){
			num[i] = sc.nextInt();
		}	
		int max = -1000000000;
		int nowm = num[0];
		for(int i=1;i<n;i++){
			max = (int)Math.max(max, num[i] - nowm);
			nowm = (int)Math.min(nowm, num[i]);	
		}

		System.out.println(max);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] num = new int[n]; num new int[n] n for(int i=0;i<n;i++){
			num[i] = sc.nextInt();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			num[i] = sc.nextInt();
		} {
			num[i] = sc.nextInt();
		} num[i] = sc.nextInt() num[i] num i sc.nextInt() sc.nextInt sc int max = -1000000000; max -1000000000 1000000000 int nowm = num[0]; nowm num[0] num 0 for(int i=1;i<n;i++){
			max = (int)Math.max(max, num[i] - nowm);
			nowm = (int)Math.min(nowm, num[i]);	
		} int i=1; int i=1; i 1 i<n i n i++ i++ i {
			max = (int)Math.max(max, num[i] - nowm);
			nowm = (int)Math.min(nowm, num[i]);	
		} {
			max = (int)Math.max(max, num[i] - nowm);
			nowm = (int)Math.min(nowm, num[i]);	
		} max = (int)Math.max(max, num[i] - nowm) max (int)Math.max(max, num[i] - nowm) Math.max Math max num[i] - nowm num[i] num i nowm nowm = (int)Math.min(nowm, num[i]) nowm (int)Math.min(nowm, num[i]) Math.min Math nowm num[i] num i System.out.println(max) System.out.println System.out System System.out max

import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] num = new int[n];
		for(int i=0;i<n;i++){
			num[i] = sc.nextInt();
		}	
		int max = -1000000000;
		int nowm = num[0];
		for(int i=1;i<n;i++){
			max = (int)Math.max(max, num[i] - nowm);
			nowm = (int)Math.min(nowm, num[i]);	
		}

		System.out.println(max);
	}
}


