import java.io.*;
  
class Main{
  
static final PrintWriter out=new PrintWriter(System.out);
  
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] r=new int[n];
for(int i=0;i<n;i++) r[i]=Integer.parseInt(br.readLine());
int ans=Integer.MIN_VALUE;
int min=r[0];
for(int i=1;i<n;i++){
ans=Math.max(ans,r[i]-min);
min=Math.min(min,r[i]);
}
out.println(ans);
out.flush();
}
}
} import java.io.*; io.* java class Main{
  
static final PrintWriter out=new PrintWriter(System.out);
  
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] r=new int[n];
for(int i=0;i<n;i++) r[i]=Integer.parseInt(br.readLine());
int ans=Integer.MIN_VALUE;
int min=r[0];
for(int i=1;i<n;i++){
ans=Math.max(ans,r[i]-min);
min=Math.min(min,r[i]);
}
out.println(ans);
out.flush();
}
}
} Main static final PrintWriter out=new PrintWriter(System.out); out new PrintWriter(System.out) public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] r=new int[n];
for(int i=0;i<n;i++) r[i]=Integer.parseInt(br.readLine());
int ans=Integer.MIN_VALUE;
int min=r[0];
for(int i=1;i<n;i++){
ans=Math.max(ans,r[i]-min);
min=Math.min(min,r[i]);
}
out.println(ans);
out.flush();
}
} main {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] r=new int[n];
for(int i=0;i<n;i++) r[i]=Integer.parseInt(br.readLine());
int ans=Integer.MIN_VALUE;
int min=r[0];
for(int i=1;i<n;i++){
ans=Math.max(ans,r[i]-min);
min=Math.min(min,r[i]);
}
out.println(ans);
out.flush();
}
} BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line=""; line "" while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] r=new int[n];
for(int i=0;i<n;i++) r[i]=Integer.parseInt(br.readLine());
int ans=Integer.MIN_VALUE;
int min=r[0];
for(int i=1;i<n;i++){
ans=Math.max(ans,r[i]-min);
min=Math.min(min,r[i]);
}
out.println(ans);
out.flush();
} (line=br.readLine())!=null&&!line.isEmpty() (line=br.readLine())!=null (line=br.readLine()) line br.readLine() br.readLine br null !line.isEmpty() line.isEmpty() line.isEmpty line {
int n=Integer.parseInt(line);
int[] r=new int[n];
for(int i=0;i<n;i++) r[i]=Integer.parseInt(br.readLine());
int ans=Integer.MIN_VALUE;
int min=r[0];
for(int i=1;i<n;i++){
ans=Math.max(ans,r[i]-min);
min=Math.min(min,r[i]);
}
out.println(ans);
out.flush();
} int n=Integer.parseInt(line); n Integer.parseInt(line) Integer.parseInt Integer line int[] r=new int[n]; r new int[n] n for(int i=0;i<n;i++) r[i]=Integer.parseInt(br.readLine()); int i=0; int i=0; i 0 i<n i n i++ i++ i r[i]=Integer.parseInt(br.readLine()); r[i]=Integer.parseInt(br.readLine()) r[i] r i Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int ans=Integer.MIN_VALUE; ans Integer.MIN_VALUE Integer Integer.MIN_VALUE int min=r[0]; min r[0] r 0 for(int i=1;i<n;i++){
ans=Math.max(ans,r[i]-min);
min=Math.min(min,r[i]);
} int i=1; int i=1; i 1 i<n i n i++ i++ i {
ans=Math.max(ans,r[i]-min);
min=Math.min(min,r[i]);
} {
ans=Math.max(ans,r[i]-min);
min=Math.min(min,r[i]);
} ans=Math.max(ans,r[i]-min) ans Math.max(ans,r[i]-min) Math.max Math ans r[i]-min r[i] r i min min=Math.min(min,r[i]) min Math.min(min,r[i]) Math.min Math min r[i] r i out.println(ans) out.println out ans out.flush() out.flush out String[] args args
import java.io.*;
  
class Main{
  
static final PrintWriter out=new PrintWriter(System.out);
  
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] r=new int[n];
for(int i=0;i<n;i++) r[i]=Integer.parseInt(br.readLine());
int ans=Integer.MIN_VALUE;
int min=r[0];
for(int i=1;i<n;i++){
ans=Math.max(ans,r[i]-min);
min=Math.min(min,r[i]);
}
out.println(ans);
out.flush();
}
}
}