import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
  
public class Main {
  
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
          
        int n=Integer.parseInt(br.readLine());
        int [] in=new int[n];
        int max=Integer.MIN_VALUE;
        int mini=0;  
        for(int i=0;i<n;i++)
            in[i]=Integer.parseInt(br.readLine());
              
        for(int i=0;i<n-1;i++){if(in[i]>in[mini])continue;
            for(int j=i+1;j<n;j++){
                int tmp=in[j]-in[i];
                if(tmp>max) {max=tmp;mini=i;}
            }
        }
System.out.println(max);
  
  
  
  
    }
  
} import java.io.BufferedReader; BufferedReader java.io import java.io.FileNotFoundException; FileNotFoundException java.io import java.io.FileReader; FileReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
  
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
          
        int n=Integer.parseInt(br.readLine());
        int [] in=new int[n];
        int max=Integer.MIN_VALUE;
        int mini=0;  
        for(int i=0;i<n;i++)
            in[i]=Integer.parseInt(br.readLine());
              
        for(int i=0;i<n-1;i++){if(in[i]>in[mini])continue;
            for(int j=i+1;j<n;j++){
                int tmp=in[j]-in[i];
                if(tmp>max) {max=tmp;mini=i;}
            }
        }
System.out.println(max);
  
  
  
  
    }
  
} Main public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
          
        int n=Integer.parseInt(br.readLine());
        int [] in=new int[n];
        int max=Integer.MIN_VALUE;
        int mini=0;  
        for(int i=0;i<n;i++)
            in[i]=Integer.parseInt(br.readLine());
              
        for(int i=0;i<n-1;i++){if(in[i]>in[mini])continue;
            for(int j=i+1;j<n;j++){
                int tmp=in[j]-in[i];
                if(tmp>max) {max=tmp;mini=i;}
            }
        }
System.out.println(max);
  
  
  
  
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
          
        int n=Integer.parseInt(br.readLine());
        int [] in=new int[n];
        int max=Integer.MIN_VALUE;
        int mini=0;  
        for(int i=0;i<n;i++)
            in[i]=Integer.parseInt(br.readLine());
              
        for(int i=0;i<n-1;i++){if(in[i]>in[mini])continue;
            for(int j=i+1;j<n;j++){
                int tmp=in[j]-in[i];
                if(tmp>max) {max=tmp;mini=i;}
            }
        }
System.out.println(max);
  
  
  
  
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int n=Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int [] in=new int[n]; in new int[n] n int max=Integer.MIN_VALUE; max Integer.MIN_VALUE Integer Integer.MIN_VALUE int mini=0; mini 0 for(int i=0;i<n;i++)
            in[i]=Integer.parseInt(br.readLine()); int i=0; int i=0; i 0 i<n i n i++ i++ i in[i]=Integer.parseInt(br.readLine()); in[i]=Integer.parseInt(br.readLine()) in[i] in i Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for(int i=0;i<n-1;i++){if(in[i]>in[mini])continue;
            for(int j=i+1;j<n;j++){
                int tmp=in[j]-in[i];
                if(tmp>max) {max=tmp;mini=i;}
            }
        } int i=0; int i=0; i 0 i<n-1 i n-1 n 1 i++ i++ i {if(in[i]>in[mini])continue;
            for(int j=i+1;j<n;j++){
                int tmp=in[j]-in[i];
                if(tmp>max) {max=tmp;mini=i;}
            }
        } {if(in[i]>in[mini])continue;
            for(int j=i+1;j<n;j++){
                int tmp=in[j]-in[i];
                if(tmp>max) {max=tmp;mini=i;}
            }
        } if(in[i]>in[mini])continue; in[i]>in[mini] in[i] in i in[mini] in mini continue; for(int j=i+1;j<n;j++){
                int tmp=in[j]-in[i];
                if(tmp>max) {max=tmp;mini=i;}
            } int j=i+1; int j=i+1; j i+1 i 1 j<n j n j++ j++ j {
                int tmp=in[j]-in[i];
                if(tmp>max) {max=tmp;mini=i;}
            } {
                int tmp=in[j]-in[i];
                if(tmp>max) {max=tmp;mini=i;}
            } int tmp=in[j]-in[i]; tmp in[j]-in[i] in[j] in j in[i] in i if(tmp>max) {max=tmp;mini=i;} tmp>max tmp max {max=tmp;mini=i;} max=tmp max tmp mini=i mini i System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main {
  
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
          
        int n=Integer.parseInt(br.readLine());
        int [] in=new int[n];
        int max=Integer.MIN_VALUE;
        int mini=0;  
        for(int i=0;i<n;i++)
            in[i]=Integer.parseInt(br.readLine());
              
        for(int i=0;i<n-1;i++){if(in[i]>in[mini])continue;
            for(int j=i+1;j<n;j++){
                int tmp=in[j]-in[i];
                if(tmp>max) {max=tmp;mini=i;}
            }
        }
System.out.println(max);
  
  
  
  
    }
  
} public class Main {
  
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
          
        int n=Integer.parseInt(br.readLine());
        int [] in=new int[n];
        int max=Integer.MIN_VALUE;
        int mini=0;  
        for(int i=0;i<n;i++)
            in[i]=Integer.parseInt(br.readLine());
              
        for(int i=0;i<n-1;i++){if(in[i]>in[mini])continue;
            for(int j=i+1;j<n;j++){
                int tmp=in[j]-in[i];
                if(tmp>max) {max=tmp;mini=i;}
            }
        }
System.out.println(max);
  
  
  
  
    }
  
} Main
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
  
public class Main {
  
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
          
        int n=Integer.parseInt(br.readLine());
        int [] in=new int[n];
        int max=Integer.MIN_VALUE;
        int mini=0;  
        for(int i=0;i<n;i++)
            in[i]=Integer.parseInt(br.readLine());
              
        for(int i=0;i<n-1;i++){if(in[i]>in[mini])continue;
            for(int j=i+1;j<n;j++){
                int tmp=in[j]-in[i];
                if(tmp>max) {max=tmp;mini=i;}
            }
        }
System.out.println(max);
  
  
  
  
    }
  
}