https://www.acmicpc.net/problem/2846
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner s=new Scanner(System.in);
int n=s.nextInt();
int a=s.nextInt();
int b=a;
int max=0;
for(int i=0;i<n-1;i++){
int p=s.nextInt();
if(p>b){
b=p;
if(b-a>max) max=b-a;
}
else{
a=p;
b=a;
}
}
System.out.format("%d",max);
}
}