/*
 * climber.java
 *
 * Created on July 6, 2004, 5:04 PM
 */
import java.io.*;
import java.util.*;
import java.lang.*;

/**
 *
 * @author  honors
 */
public class Climber {
    int[] array;
    
    /** Creates a new instance of climber */
    public Climber() throws Exception {
        BufferedReader br = new BufferedReader(new FileReader("mnt100000.txt"));
        
        int numValues = Integer.parseInt(br.readLine());
        
        array = new int[numValues];
        for(int a=0;a<array.length;a++)
        {
            array[a] = Integer.parseInt(br.readLine());
        }
        
        long tStart = System.currentTimeMillis();
        bruteSolution();
        System.out.println("Brute force solution ran in "+(System.currentTimeMillis()-tStart)+" milliseconds.");
        tStart = System.currentTimeMillis();
        fastSolution();
        System.out.println("Fast solution ran in "+((System.currentTimeMillis()-tStart)/1.0)+" milliseconds.");
    }
    
    public void bruteSolution()
    {
        int bestClimb = 0;
        for(int a=0;a<array.length;a++)
        {
            for(int b=a+1;b<array.length;b++)
            {
                bestClimb = Math.max(bestClimb,array[b]-array[a]);
            }
        }
        System.out.println("Best Climb: "+bestClimb);
    }
    
    public void fastSolution()
    {
        int bestClimb = 0;
        int lowestVal=array[0];
        for(int a=1;a<array.length;a++)
        {
            bestClimb = Math.max(bestClimb,array[a]-lowestVal);
            lowestVal = Math.min(lowestVal,array[a]);
        }
        System.out.println("Best Climb: "+bestClimb);
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        // TODO code application logic here
        new Climber();
    }
    
}
