import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        int n = readInt(r);
        
        if (n <= 1) {
            output(-1);
            return;
        } else {
            int r_i = readInt(r);
            int r_j = readInt(r);
            int delta = r_j - r_i;
            int maxDelta = delta;
            
            if (r_i > r_j) {
                r_i = r_j;
            }

            for (int i = 0;i < (n -2);i++) {
                r_j = readInt(r);
                delta = r_j - r_i;
                if (delta > maxDelta) {
                    maxDelta = delta;
                }

                if (r_i > r_j) {
                    r_i = r_j;
                }
            }
            
            output(maxDelta);
        }
    }

    public static void output(int x) {
        System.out.println(x);
    }

    public static int readInt(BufferedReader r) throws Exception {
        return Integer.parseInt(r.readLine());
    }
} 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 r = new BufferedReader(new InputStreamReader(System.in));
        int n = readInt(r);
        
        if (n <= 1) {
            output(-1);
            return;
        } else {
            int r_i = readInt(r);
            int r_j = readInt(r);
            int delta = r_j - r_i;
            int maxDelta = delta;
            
            if (r_i > r_j) {
                r_i = r_j;
            }

            for (int i = 0;i < (n -2);i++) {
                r_j = readInt(r);
                delta = r_j - r_i;
                if (delta > maxDelta) {
                    maxDelta = delta;
                }

                if (r_i > r_j) {
                    r_i = r_j;
                }
            }
            
            output(maxDelta);
        }
    }

    public static void output(int x) {
        System.out.println(x);
    }

    public static int readInt(BufferedReader r) throws Exception {
        return Integer.parseInt(r.readLine());
    }
} Main public static void main(String[] args) throws Exception {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        int n = readInt(r);
        
        if (n <= 1) {
            output(-1);
            return;
        } else {
            int r_i = readInt(r);
            int r_j = readInt(r);
            int delta = r_j - r_i;
            int maxDelta = delta;
            
            if (r_i > r_j) {
                r_i = r_j;
            }

            for (int i = 0;i < (n -2);i++) {
                r_j = readInt(r);
                delta = r_j - r_i;
                if (delta > maxDelta) {
                    maxDelta = delta;
                }

                if (r_i > r_j) {
                    r_i = r_j;
                }
            }
            
            output(maxDelta);
        }
    } main {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        int n = readInt(r);
        
        if (n <= 1) {
            output(-1);
            return;
        } else {
            int r_i = readInt(r);
            int r_j = readInt(r);
            int delta = r_j - r_i;
            int maxDelta = delta;
            
            if (r_i > r_j) {
                r_i = r_j;
            }

            for (int i = 0;i < (n -2);i++) {
                r_j = readInt(r);
                delta = r_j - r_i;
                if (delta > maxDelta) {
                    maxDelta = delta;
                }

                if (r_i > r_j) {
                    r_i = r_j;
                }
            }
            
            output(maxDelta);
        }
    } BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); r new BufferedReader(new InputStreamReader(System.in)) int n = readInt(r); n readInt(r) readInt r if (n <= 1) {
            output(-1);
            return;
        } else {
            int r_i = readInt(r);
            int r_j = readInt(r);
            int delta = r_j - r_i;
            int maxDelta = delta;
            
            if (r_i > r_j) {
                r_i = r_j;
            }

            for (int i = 0;i < (n -2);i++) {
                r_j = readInt(r);
                delta = r_j - r_i;
                if (delta > maxDelta) {
                    maxDelta = delta;
                }

                if (r_i > r_j) {
                    r_i = r_j;
                }
            }
            
            output(maxDelta);
        } n <= 1 n 1 {
            output(-1);
            return;
        } output(-1) output -1 1 return; {
            int r_i = readInt(r);
            int r_j = readInt(r);
            int delta = r_j - r_i;
            int maxDelta = delta;
            
            if (r_i > r_j) {
                r_i = r_j;
            }

            for (int i = 0;i < (n -2);i++) {
                r_j = readInt(r);
                delta = r_j - r_i;
                if (delta > maxDelta) {
                    maxDelta = delta;
                }

                if (r_i > r_j) {
                    r_i = r_j;
                }
            }
            
            output(maxDelta);
        } int r_i = readInt(r); r_i readInt(r) readInt r int r_j = readInt(r); r_j readInt(r) readInt r int delta = r_j - r_i; delta r_j - r_i r_j r_i int maxDelta = delta; maxDelta delta if (r_i > r_j) {
                r_i = r_j;
            } r_i > r_j r_i r_j {
                r_i = r_j;
            } r_i = r_j r_i r_j for (int i = 0;i < (n -2);i++) {
                r_j = readInt(r);
                delta = r_j - r_i;
                if (delta > maxDelta) {
                    maxDelta = delta;
                }

                if (r_i > r_j) {
                    r_i = r_j;
                }
            } int i = 0; int i = 0; i 0 i < (n -2) i (n -2) n 2 i++ i++ i {
                r_j = readInt(r);
                delta = r_j - r_i;
                if (delta > maxDelta) {
                    maxDelta = delta;
                }

                if (r_i > r_j) {
                    r_i = r_j;
                }
            } {
                r_j = readInt(r);
                delta = r_j - r_i;
                if (delta > maxDelta) {
                    maxDelta = delta;
                }

                if (r_i > r_j) {
                    r_i = r_j;
                }
            } r_j = readInt(r) r_j readInt(r) readInt r delta = r_j - r_i delta r_j - r_i r_j r_i if (delta > maxDelta) {
                    maxDelta = delta;
                } delta > maxDelta delta maxDelta {
                    maxDelta = delta;
                } maxDelta = delta maxDelta delta if (r_i > r_j) {
                    r_i = r_j;
                } r_i > r_j r_i r_j {
                    r_i = r_j;
                } r_i = r_j r_i r_j output(maxDelta) output maxDelta String[] args args public static void output(int x) {
        System.out.println(x);
    } output {
        System.out.println(x);
    } System.out.println(x) System.out.println System.out System System.out x int x x public static int readInt(BufferedReader r) throws Exception {
        return Integer.parseInt(r.readLine());
    } readInt {
        return Integer.parseInt(r.readLine());
    } return Integer.parseInt(r.readLine()); Integer.parseInt(r.readLine()) Integer.parseInt Integer r.readLine() r.readLine r BufferedReader r r public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        int n = readInt(r);
        
        if (n <= 1) {
            output(-1);
            return;
        } else {
            int r_i = readInt(r);
            int r_j = readInt(r);
            int delta = r_j - r_i;
            int maxDelta = delta;
            
            if (r_i > r_j) {
                r_i = r_j;
            }

            for (int i = 0;i < (n -2);i++) {
                r_j = readInt(r);
                delta = r_j - r_i;
                if (delta > maxDelta) {
                    maxDelta = delta;
                }

                if (r_i > r_j) {
                    r_i = r_j;
                }
            }
            
            output(maxDelta);
        }
    }

    public static void output(int x) {
        System.out.println(x);
    }

    public static int readInt(BufferedReader r) throws Exception {
        return Integer.parseInt(r.readLine());
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        int n = readInt(r);
        
        if (n <= 1) {
            output(-1);
            return;
        } else {
            int r_i = readInt(r);
            int r_j = readInt(r);
            int delta = r_j - r_i;
            int maxDelta = delta;
            
            if (r_i > r_j) {
                r_i = r_j;
            }

            for (int i = 0;i < (n -2);i++) {
                r_j = readInt(r);
                delta = r_j - r_i;
                if (delta > maxDelta) {
                    maxDelta = delta;
                }

                if (r_i > r_j) {
                    r_i = r_j;
                }
            }
            
            output(maxDelta);
        }
    }

    public static void output(int x) {
        System.out.println(x);
    }

    public static int readInt(BufferedReader r) throws Exception {
        return Integer.parseInt(r.readLine());
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        int n = readInt(r);
        
        if (n <= 1) {
            output(-1);
            return;
        } else {
            int r_i = readInt(r);
            int r_j = readInt(r);
            int delta = r_j - r_i;
            int maxDelta = delta;
            
            if (r_i > r_j) {
                r_i = r_j;
            }

            for (int i = 0;i < (n -2);i++) {
                r_j = readInt(r);
                delta = r_j - r_i;
                if (delta > maxDelta) {
                    maxDelta = delta;
                }

                if (r_i > r_j) {
                    r_i = r_j;
                }
            }
            
            output(maxDelta);
        }
    }

    public static void output(int x) {
        System.out.println(x);
    }

    public static int readInt(BufferedReader r) throws Exception {
        return Integer.parseInt(r.readLine());
    }
}