import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		ContestScanner scan = new ContestScanner();

		int n = scan.nextInt();

		int[] R = new int[n];

		for(int i=0; i < n; i++)
		{
			R[i] = scan.nextInt();
		}

		(new Solve(n, R)).solve();
	}
}
class Solve {
	private final int n;
	private final int[] R;

	public Solve(final int n, final int[] R)
	{
		this.n = n;
		this.R = R;
	}

	public void solve()
	{
		int max = R[1] - R[0];
		int left = R[0];

		for(int i=1; i < n; i++)
		{
			max = Math.max(max, R[i] - left);
			left = Math.min(left, R[i]);
		}

		System.out.println(max);
	}
}
class ContestScanner {
	BufferedReader reader;
	String[] line;
	int index;
	public ContestScanner() {
		reader = new BufferedReader(new InputStreamReader(System.in));
	}

	public ContestScanner(String filename) throws FileNotFoundException {
		reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
	}

	public String nextToken() throws IOException {
		if(line == null || index >= line.length)
		{
			line = reader.readLine().trim().split(" ");
			index = 0;
		}

		return line[index++];
	}

	public String next() throws IOException {
		return nextToken();
	}

	public String readLine() throws IOException {
		line = null;
		index = 0;

		return reader.readLine();
	}

	public int nextInt() throws IOException, NumberFormatException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException, NumberFormatException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException, NumberFormatException {
		return Double.parseDouble(nextToken());
	}

	public int[] nextIntArray(int N) throws IOException, NumberFormatException {
		int[] result = new int[N];

		for(int i=0; i < N; i++) result[i] = nextInt();

		return result;
	}

	public long[] nextLongArray(int N) throws IOException, NumberFormatException {
		long[] result = new long[N];

		for(int i=0; i < N; i++) result[i] = nextLong();

		return result;
	}

	public double[] nexDoubleArray(int N) throws IOException, NumberFormatException {
		double[] result = new double[N];

		for(int i=0; i < N; i++) result[i] = nextDouble();

		return result;
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.FileInputStream; FileInputStream java.io import java.io.FileNotFoundException; FileNotFoundException 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 IOException {
		ContestScanner scan = new ContestScanner();

		int n = scan.nextInt();

		int[] R = new int[n];

		for(int i=0; i < n; i++)
		{
			R[i] = scan.nextInt();
		}

		(new Solve(n, R)).solve();
	}
} Main public static void main(String[] args) throws IOException {
		ContestScanner scan = new ContestScanner();

		int n = scan.nextInt();

		int[] R = new int[n];

		for(int i=0; i < n; i++)
		{
			R[i] = scan.nextInt();
		}

		(new Solve(n, R)).solve();
	} main {
		ContestScanner scan = new ContestScanner();

		int n = scan.nextInt();

		int[] R = new int[n];

		for(int i=0; i < n; i++)
		{
			R[i] = scan.nextInt();
		}

		(new Solve(n, R)).solve();
	} ContestScanner scan = new ContestScanner(); scan new ContestScanner() int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int[] R = new int[n]; R new int[n] n for(int i=0; i < n; i++)
		{
			R[i] = scan.nextInt();
		} int i=0; int i=0; i 0 i < n i n i++ i++ i {
			R[i] = scan.nextInt();
		} {
			R[i] = scan.nextInt();
		} R[i] = scan.nextInt() R[i] R i scan.nextInt() scan.nextInt scan (new Solve(n, R)).solve() (new Solve(n, R)).solve (new Solve(n, R)) String[] args args class Solve {
	private final int n;
	private final int[] R;

	public Solve(final int n, final int[] R)
	{
		this.n = n;
		this.R = R;
	}

	public void solve()
	{
		int max = R[1] - R[0];
		int left = R[0];

		for(int i=1; i < n; i++)
		{
			max = Math.max(max, R[i] - left);
			left = Math.min(left, R[i]);
		}

		System.out.println(max);
	}
} Solve private final int n; n private final int[] R; R public Solve(final int n, final int[] R)
	{
		this.n = n;
		this.R = R;
	} Solve {
		this.n = n;
		this.R = R;
	} this.n = n this.n this this.n n this.R = R this.R this this.R R final int n n final int[] R R public void solve()
	{
		int max = R[1] - R[0];
		int left = R[0];

		for(int i=1; i < n; i++)
		{
			max = Math.max(max, R[i] - left);
			left = Math.min(left, R[i]);
		}

		System.out.println(max);
	} solve {
		int max = R[1] - R[0];
		int left = R[0];

		for(int i=1; i < n; i++)
		{
			max = Math.max(max, R[i] - left);
			left = Math.min(left, R[i]);
		}

		System.out.println(max);
	} int max = R[1] - R[0]; max R[1] - R[0] R[1] R 1 R[0] R 0 int left = R[0]; left R[0] R 0 for(int i=1; i < n; i++)
		{
			max = Math.max(max, R[i] - left);
			left = Math.min(left, R[i]);
		} int i=1; int i=1; i 1 i < n i n i++ i++ i {
			max = Math.max(max, R[i] - left);
			left = Math.min(left, R[i]);
		} {
			max = Math.max(max, R[i] - left);
			left = Math.min(left, R[i]);
		} max = Math.max(max, R[i] - left) max Math.max(max, R[i] - left) Math.max Math max R[i] - left R[i] R i left left = Math.min(left, R[i]) left Math.min(left, R[i]) Math.min Math left R[i] R i System.out.println(max) System.out.println System.out System System.out max class ContestScanner {
	BufferedReader reader;
	String[] line;
	int index;
	public ContestScanner() {
		reader = new BufferedReader(new InputStreamReader(System.in));
	}

	public ContestScanner(String filename) throws FileNotFoundException {
		reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
	}

	public String nextToken() throws IOException {
		if(line == null || index >= line.length)
		{
			line = reader.readLine().trim().split(" ");
			index = 0;
		}

		return line[index++];
	}

	public String next() throws IOException {
		return nextToken();
	}

	public String readLine() throws IOException {
		line = null;
		index = 0;

		return reader.readLine();
	}

	public int nextInt() throws IOException, NumberFormatException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException, NumberFormatException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException, NumberFormatException {
		return Double.parseDouble(nextToken());
	}

	public int[] nextIntArray(int N) throws IOException, NumberFormatException {
		int[] result = new int[N];

		for(int i=0; i < N; i++) result[i] = nextInt();

		return result;
	}

	public long[] nextLongArray(int N) throws IOException, NumberFormatException {
		long[] result = new long[N];

		for(int i=0; i < N; i++) result[i] = nextLong();

		return result;
	}

	public double[] nexDoubleArray(int N) throws IOException, NumberFormatException {
		double[] result = new double[N];

		for(int i=0; i < N; i++) result[i] = nextDouble();

		return result;
	}
} ContestScanner BufferedReader reader; reader String[] line; line int index; index public ContestScanner() {
		reader = new BufferedReader(new InputStreamReader(System.in));
	} ContestScanner {
		reader = new BufferedReader(new InputStreamReader(System.in));
	} reader = new BufferedReader(new InputStreamReader(System.in)) reader new BufferedReader(new InputStreamReader(System.in)) public ContestScanner(String filename) throws FileNotFoundException {
		reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
	} ContestScanner {
		reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
	} reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename))) reader new BufferedReader(new InputStreamReader(new FileInputStream(filename))) String filename filename public String nextToken() throws IOException {
		if(line == null || index >= line.length)
		{
			line = reader.readLine().trim().split(" ");
			index = 0;
		}

		return line[index++];
	} nextToken {
		if(line == null || index >= line.length)
		{
			line = reader.readLine().trim().split(" ");
			index = 0;
		}

		return line[index++];
	} if(line == null || index >= line.length)
		{
			line = reader.readLine().trim().split(" ");
			index = 0;
		} line == null || index >= line.length line == null line null index >= line.length index line.length line line.length {
			line = reader.readLine().trim().split(" ");
			index = 0;
		} line = reader.readLine().trim().split(" ") line reader.readLine().trim().split(" ") reader.readLine().trim().split reader.readLine().trim() reader.readLine().trim reader.readLine() reader.readLine reader " " index = 0 index 0 return line[index++]; line[index++] line index++ index public String next() throws IOException {
		return nextToken();
	} next {
		return nextToken();
	} return nextToken(); nextToken() nextToken public String readLine() throws IOException {
		line = null;
		index = 0;

		return reader.readLine();
	} readLine {
		line = null;
		index = 0;

		return reader.readLine();
	} line = null line null index = 0 index 0 return reader.readLine(); reader.readLine() reader.readLine reader public int nextInt() throws IOException, NumberFormatException {
		return Integer.parseInt(nextToken());
	} nextInt {
		return Integer.parseInt(nextToken());
	} return Integer.parseInt(nextToken()); Integer.parseInt(nextToken()) Integer.parseInt Integer nextToken() nextToken public long nextLong() throws IOException, NumberFormatException {
		return Long.parseLong(nextToken());
	} nextLong {
		return Long.parseLong(nextToken());
	} return Long.parseLong(nextToken()); Long.parseLong(nextToken()) Long.parseLong Long nextToken() nextToken public double nextDouble() throws IOException, NumberFormatException {
		return Double.parseDouble(nextToken());
	} nextDouble {
		return Double.parseDouble(nextToken());
	} return Double.parseDouble(nextToken()); Double.parseDouble(nextToken()) Double.parseDouble Double nextToken() nextToken public int[] nextIntArray(int N) throws IOException, NumberFormatException {
		int[] result = new int[N];

		for(int i=0; i < N; i++) result[i] = nextInt();

		return result;
	} nextIntArray {
		int[] result = new int[N];

		for(int i=0; i < N; i++) result[i] = nextInt();

		return result;
	} int[] result = new int[N]; result new int[N] N for(int i=0; i < N; i++) result[i] = nextInt(); int i=0; int i=0; i 0 i < N i N i++ i++ i result[i] = nextInt(); result[i] = nextInt() result[i] result i nextInt() nextInt return result; result int N N public long[] nextLongArray(int N) throws IOException, NumberFormatException {
		long[] result = new long[N];

		for(int i=0; i < N; i++) result[i] = nextLong();

		return result;
	} nextLongArray {
		long[] result = new long[N];

		for(int i=0; i < N; i++) result[i] = nextLong();

		return result;
	} long[] result = new long[N]; result new long[N] N for(int i=0; i < N; i++) result[i] = nextLong(); int i=0; int i=0; i 0 i < N i N i++ i++ i result[i] = nextLong(); result[i] = nextLong() result[i] result i nextLong() nextLong return result; result int N N public double[] nexDoubleArray(int N) throws IOException, NumberFormatException {
		double[] result = new double[N];

		for(int i=0; i < N; i++) result[i] = nextDouble();

		return result;
	} nexDoubleArray {
		double[] result = new double[N];

		for(int i=0; i < N; i++) result[i] = nextDouble();

		return result;
	} double[] result = new double[N]; result new double[N] N for(int i=0; i < N; i++) result[i] = nextDouble(); int i=0; int i=0; i 0 i < N i N i++ i++ i result[i] = nextDouble(); result[i] = nextDouble() result[i] result i nextDouble() nextDouble return result; result int N N public class Main {

	public static void main(String[] args) throws IOException {
		ContestScanner scan = new ContestScanner();

		int n = scan.nextInt();

		int[] R = new int[n];

		for(int i=0; i < n; i++)
		{
			R[i] = scan.nextInt();
		}

		(new Solve(n, R)).solve();
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		ContestScanner scan = new ContestScanner();

		int n = scan.nextInt();

		int[] R = new int[n];

		for(int i=0; i < n; i++)
		{
			R[i] = scan.nextInt();
		}

		(new Solve(n, R)).solve();
	}
} Main
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		ContestScanner scan = new ContestScanner();

		int n = scan.nextInt();

		int[] R = new int[n];

		for(int i=0; i < n; i++)
		{
			R[i] = scan.nextInt();
		}

		(new Solve(n, R)).solve();
	}
}
class Solve {
	private final int n;
	private final int[] R;

	public Solve(final int n, final int[] R)
	{
		this.n = n;
		this.R = R;
	}

	public void solve()
	{
		int max = R[1] - R[0];
		int left = R[0];

		for(int i=1; i < n; i++)
		{
			max = Math.max(max, R[i] - left);
			left = Math.min(left, R[i]);
		}

		System.out.println(max);
	}
}
class ContestScanner {
	BufferedReader reader;
	String[] line;
	int index;
	public ContestScanner() {
		reader = new BufferedReader(new InputStreamReader(System.in));
	}

	public ContestScanner(String filename) throws FileNotFoundException {
		reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
	}

	public String nextToken() throws IOException {
		if(line == null || index >= line.length)
		{
			line = reader.readLine().trim().split(" ");
			index = 0;
		}

		return line[index++];
	}

	public String next() throws IOException {
		return nextToken();
	}

	public String readLine() throws IOException {
		line = null;
		index = 0;

		return reader.readLine();
	}

	public int nextInt() throws IOException, NumberFormatException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException, NumberFormatException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException, NumberFormatException {
		return Double.parseDouble(nextToken());
	}

	public int[] nextIntArray(int N) throws IOException, NumberFormatException {
		int[] result = new int[N];

		for(int i=0; i < N; i++) result[i] = nextInt();

		return result;
	}

	public long[] nextLongArray(int N) throws IOException, NumberFormatException {
		long[] result = new long[N];

		for(int i=0; i < N; i++) result[i] = nextLong();

		return result;
	}

	public double[] nexDoubleArray(int N) throws IOException, NumberFormatException {
		double[] result = new double[N];

		for(int i=0; i < N; i++) result[i] = nextDouble();

		return result;
	}
}