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 num =Integer.parseInt(br.readLine());
        //??????????°???? ???????????????????¨??????????
        int min = Integer.parseInt(br.readLine());
        //?????§?????? ????????????????????????????????????????????§??????????????????????????????????¨??????????
        int maxProfit = -1000000000;
        int currentNum = 0;
        for(int i = 1 ; i < num ; i++){
        	currentNum = Integer.parseInt(br.readLine());
        	maxProfit = Math.max(maxProfit, currentNum - min);
        	min = Math.min(min, currentNum);
        }
        
        System.out.println(maxProfit);

	}

} 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 num =Integer.parseInt(br.readLine());
        //??????????°???? ???????????????????¨??????????
        int min = Integer.parseInt(br.readLine());
        //?????§?????? ????????????????????????????????????????????§??????????????????????????????????¨??????????
        int maxProfit = -1000000000;
        int currentNum = 0;
        for(int i = 1 ; i < num ; i++){
        	currentNum = Integer.parseInt(br.readLine());
        	maxProfit = Math.max(maxProfit, currentNum - min);
        	min = Math.min(min, currentNum);
        }
        
        System.out.println(maxProfit);

	}

} Main public static void main(String[] args) throws Exception {
		//??\??????????????????
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //????????????????????°?????????
        int num =Integer.parseInt(br.readLine());
        //??????????°???? ???????????????????¨??????????
        int min = Integer.parseInt(br.readLine());
        //?????§?????? ????????????????????????????????????????????§??????????????????????????????????¨??????????
        int maxProfit = -1000000000;
        int currentNum = 0;
        for(int i = 1 ; i < num ; i++){
        	currentNum = Integer.parseInt(br.readLine());
        	maxProfit = Math.max(maxProfit, currentNum - min);
        	min = Math.min(min, currentNum);
        }
        
        System.out.println(maxProfit);

	} main {
		//??\??????????????????
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //????????????????????°?????????
        int num =Integer.parseInt(br.readLine());
        //??????????°???? ???????????????????¨??????????
        int min = Integer.parseInt(br.readLine());
        //?????§?????? ????????????????????????????????????????????§??????????????????????????????????¨??????????
        int maxProfit = -1000000000;
        int currentNum = 0;
        for(int i = 1 ; i < num ; i++){
        	currentNum = Integer.parseInt(br.readLine());
        	maxProfit = Math.max(maxProfit, currentNum - min);
        	min = Math.min(min, currentNum);
        }
        
        System.out.println(maxProfit);

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int num =Integer.parseInt(br.readLine()); num Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int min = Integer.parseInt(br.readLine()); min Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int maxProfit = -1000000000; maxProfit -1000000000 1000000000 int currentNum = 0; currentNum 0 for(int i = 1 ; i < num ; i++){
        	currentNum = Integer.parseInt(br.readLine());
        	maxProfit = Math.max(maxProfit, currentNum - min);
        	min = Math.min(min, currentNum);
        } int i = 1 ; int i = 1 ; i 1 i < num i num i++ i++ i {
        	currentNum = Integer.parseInt(br.readLine());
        	maxProfit = Math.max(maxProfit, currentNum - min);
        	min = Math.min(min, currentNum);
        } {
        	currentNum = Integer.parseInt(br.readLine());
        	maxProfit = Math.max(maxProfit, currentNum - min);
        	min = Math.min(min, currentNum);
        } currentNum = Integer.parseInt(br.readLine()) currentNum Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br maxProfit = Math.max(maxProfit, currentNum - min) maxProfit Math.max(maxProfit, currentNum - min) Math.max Math maxProfit currentNum - min currentNum min min = Math.min(min, currentNum) min Math.min(min, currentNum) Math.min Math min currentNum System.out.println(maxProfit) System.out.println System.out System System.out maxProfit String[] args args public class Main {

	public static void main(String[] args) throws Exception {
		//??\??????????????????
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //????????????????????°?????????
        int num =Integer.parseInt(br.readLine());
        //??????????°???? ???????????????????¨??????????
        int min = Integer.parseInt(br.readLine());
        //?????§?????? ????????????????????????????????????????????§??????????????????????????????????¨??????????
        int maxProfit = -1000000000;
        int currentNum = 0;
        for(int i = 1 ; i < num ; i++){
        	currentNum = Integer.parseInt(br.readLine());
        	maxProfit = Math.max(maxProfit, currentNum - min);
        	min = Math.min(min, currentNum);
        }
        
        System.out.println(maxProfit);

	}

} public class Main {

	public static void main(String[] args) throws Exception {
		//??\??????????????????
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //????????????????????°?????????
        int num =Integer.parseInt(br.readLine());
        //??????????°???? ???????????????????¨??????????
        int min = Integer.parseInt(br.readLine());
        //?????§?????? ????????????????????????????????????????????§??????????????????????????????????¨??????????
        int maxProfit = -1000000000;
        int currentNum = 0;
        for(int i = 1 ; i < num ; i++){
        	currentNum = Integer.parseInt(br.readLine());
        	maxProfit = Math.max(maxProfit, currentNum - min);
        	min = Math.min(min, currentNum);
        }
        
        System.out.println(maxProfit);

	}

} 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 num =Integer.parseInt(br.readLine());
        //??????????°???? ???????????????????¨??????????
        int min = Integer.parseInt(br.readLine());
        //?????§?????? ????????????????????????????????????????????§??????????????????????????????????¨??????????
        int maxProfit = -1000000000;
        int currentNum = 0;
        for(int i = 1 ; i < num ; i++){
        	currentNum = Integer.parseInt(br.readLine());
        	maxProfit = Math.max(maxProfit, currentNum - min);
        	min = Math.min(min, currentNum);
        }
        
        System.out.println(maxProfit);

	}

}