import java.io.*;
 
class Main {
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            int n = Integer.parseInt( kb.readLine() );
			
			int[] nums = new int[n];
            int num, maxprofit, min;
            int i, j;
            
            maxprofit = 1-1000000000;
            min = Integer.parseInt( kb.readLine() );
            for( i=1; i<n; i++ ) {
            	num = Integer.parseInt( kb.readLine() );
				maxprofit = Math.max( maxprofit, num-min );
				min = Math.min( min, num );
            }
            
            System.out.println( maxprofit  );
             
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
} import java.io.*; io.* java class Main {
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            int n = Integer.parseInt( kb.readLine() );
			
			int[] nums = new int[n];
            int num, maxprofit, min;
            int i, j;
            
            maxprofit = 1-1000000000;
            min = Integer.parseInt( kb.readLine() );
            for( i=1; i<n; i++ ) {
            	num = Integer.parseInt( kb.readLine() );
				maxprofit = Math.max( maxprofit, num-min );
				min = Math.min( min, num );
            }
            
            System.out.println( maxprofit  );
             
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
} Main public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            int n = Integer.parseInt( kb.readLine() );
			
			int[] nums = new int[n];
            int num, maxprofit, min;
            int i, j;
            
            maxprofit = 1-1000000000;
            min = Integer.parseInt( kb.readLine() );
            for( i=1; i<n; i++ ) {
            	num = Integer.parseInt( kb.readLine() );
				maxprofit = Math.max( maxprofit, num-min );
				min = Math.min( min, num );
            }
            
            System.out.println( maxprofit  );
             
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }
    } main {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            int n = Integer.parseInt( kb.readLine() );
			
			int[] nums = new int[n];
            int num, maxprofit, min;
            int i, j;
            
            maxprofit = 1-1000000000;
            min = Integer.parseInt( kb.readLine() );
            for( i=1; i<n; i++ ) {
            	num = Integer.parseInt( kb.readLine() );
				maxprofit = Math.max( maxprofit, num-min );
				min = Math.min( min, num );
            }
            
            System.out.println( maxprofit  );
             
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }
    } BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) ); kb new BufferedReader( new InputStreamReader( System.in ) ) try {
            int n = Integer.parseInt( kb.readLine() );
			
			int[] nums = new int[n];
            int num, maxprofit, min;
            int i, j;
            
            maxprofit = 1-1000000000;
            min = Integer.parseInt( kb.readLine() );
            for( i=1; i<n; i++ ) {
            	num = Integer.parseInt( kb.readLine() );
				maxprofit = Math.max( maxprofit, num-min );
				min = Math.min( min, num );
            }
            
            System.out.println( maxprofit  );
             
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        } catch( IOException e ) {
            System.err.println( e );
        } IOException e {
            System.err.println( e );
        } System.err.println( e ) System.err.println System.err System System.err e {
            int n = Integer.parseInt( kb.readLine() );
			
			int[] nums = new int[n];
            int num, maxprofit, min;
            int i, j;
            
            maxprofit = 1-1000000000;
            min = Integer.parseInt( kb.readLine() );
            for( i=1; i<n; i++ ) {
            	num = Integer.parseInt( kb.readLine() );
				maxprofit = Math.max( maxprofit, num-min );
				min = Math.min( min, num );
            }
            
            System.out.println( maxprofit  );
             
            kb.close();
        } int n = Integer.parseInt( kb.readLine() ); n Integer.parseInt( kb.readLine() ) Integer.parseInt Integer kb.readLine() kb.readLine kb int[] nums = new int[n]; nums new int[n] n int num num maxprofit maxprofit min; min int i i j; j maxprofit = 1-1000000000 maxprofit 1-1000000000 1 1000000000 min = Integer.parseInt( kb.readLine() ) min Integer.parseInt( kb.readLine() ) Integer.parseInt Integer kb.readLine() kb.readLine kb for( i=1; i<n; i++ ) {
            	num = Integer.parseInt( kb.readLine() );
				maxprofit = Math.max( maxprofit, num-min );
				min = Math.min( min, num );
            } i=1; i=1 i 1 i<n i n i++ i++ i {
            	num = Integer.parseInt( kb.readLine() );
				maxprofit = Math.max( maxprofit, num-min );
				min = Math.min( min, num );
            } {
            	num = Integer.parseInt( kb.readLine() );
				maxprofit = Math.max( maxprofit, num-min );
				min = Math.min( min, num );
            } num = Integer.parseInt( kb.readLine() ) num Integer.parseInt( kb.readLine() ) Integer.parseInt Integer kb.readLine() kb.readLine kb maxprofit = Math.max( maxprofit, num-min ) maxprofit Math.max( maxprofit, num-min ) Math.max Math maxprofit num-min num min min = Math.min( min, num ) min Math.min( min, num ) Math.min Math min num System.out.println( maxprofit  ) System.out.println System.out System System.out maxprofit kb.close() kb.close kb String[] args args
import java.io.*;
 
class Main {
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            int n = Integer.parseInt( kb.readLine() );
			
			int[] nums = new int[n];
            int num, maxprofit, min;
            int i, j;
            
            maxprofit = 1-1000000000;
            min = Integer.parseInt( kb.readLine() );
            for( i=1; i<n; i++ ) {
            	num = Integer.parseInt( kb.readLine() );
				maxprofit = Math.max( maxprofit, num-min );
				min = Math.min( min, num );
            }
            
            System.out.println( maxprofit  );
             
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
}