import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int mnv = input.nextInt();
		int mxv, t;
		t = input.nextInt();
		mxv = t - mnv;
		if(t < mnv)
			mnv = t;	
		for(int i = 2; i < n; i++)
		{
			t = input.nextInt();
			if(t < mnv)
				mnv = t;
			else if(mxv < t - mnv)
				mxv	= t - mnv;
		}
		System.out.println(mxv);
	}
} import java.util.Scanner; Scanner java.util public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int mnv = input.nextInt();
		int mxv, t;
		t = input.nextInt();
		mxv = t - mnv;
		if(t < mnv)
			mnv = t;	
		for(int i = 2; i < n; i++)
		{
			t = input.nextInt();
			if(t < mnv)
				mnv = t;
			else if(mxv < t - mnv)
				mxv	= t - mnv;
		}
		System.out.println(mxv);
	}
} Main public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int mnv = input.nextInt();
		int mxv, t;
		t = input.nextInt();
		mxv = t - mnv;
		if(t < mnv)
			mnv = t;	
		for(int i = 2; i < n; i++)
		{
			t = input.nextInt();
			if(t < mnv)
				mnv = t;
			else if(mxv < t - mnv)
				mxv	= t - mnv;
		}
		System.out.println(mxv);
	} main {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int mnv = input.nextInt();
		int mxv, t;
		t = input.nextInt();
		mxv = t - mnv;
		if(t < mnv)
			mnv = t;	
		for(int i = 2; i < n; i++)
		{
			t = input.nextInt();
			if(t < mnv)
				mnv = t;
			else if(mxv < t - mnv)
				mxv	= t - mnv;
		}
		System.out.println(mxv);
	} Scanner input = new Scanner(System.in); input new Scanner(System.in) int n = input.nextInt(); n input.nextInt() input.nextInt input int mnv = input.nextInt(); mnv input.nextInt() input.nextInt input int mxv mxv t; t t = input.nextInt() t input.nextInt() input.nextInt input mxv = t - mnv mxv t - mnv t mnv if(t < mnv)
			mnv = t; t < mnv t mnv mnv = t mnv t for(int i = 2; i < n; i++)
		{
			t = input.nextInt();
			if(t < mnv)
				mnv = t;
			else if(mxv < t - mnv)
				mxv	= t - mnv;
		} int i = 2; int i = 2; i 2 i < n i n i++ i++ i {
			t = input.nextInt();
			if(t < mnv)
				mnv = t;
			else if(mxv < t - mnv)
				mxv	= t - mnv;
		} {
			t = input.nextInt();
			if(t < mnv)
				mnv = t;
			else if(mxv < t - mnv)
				mxv	= t - mnv;
		} t = input.nextInt() t input.nextInt() input.nextInt input if(t < mnv)
				mnv = t;
			else if(mxv < t - mnv)
				mxv	= t - mnv; t < mnv t mnv mnv = t mnv t if(mxv < t - mnv)
				mxv	= t - mnv; mxv < t - mnv mxv t - mnv t mnv mxv	= t - mnv mxv t - mnv t mnv System.out.println(mxv) System.out.println System.out System System.out mxv String args[] args public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int mnv = input.nextInt();
		int mxv, t;
		t = input.nextInt();
		mxv = t - mnv;
		if(t < mnv)
			mnv = t;	
		for(int i = 2; i < n; i++)
		{
			t = input.nextInt();
			if(t < mnv)
				mnv = t;
			else if(mxv < t - mnv)
				mxv	= t - mnv;
		}
		System.out.println(mxv);
	}
} public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int mnv = input.nextInt();
		int mxv, t;
		t = input.nextInt();
		mxv = t - mnv;
		if(t < mnv)
			mnv = t;	
		for(int i = 2; i < n; i++)
		{
			t = input.nextInt();
			if(t < mnv)
				mnv = t;
			else if(mxv < t - mnv)
				mxv	= t - mnv;
		}
		System.out.println(mxv);
	}
} Main
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int mnv = input.nextInt();
		int mxv, t;
		t = input.nextInt();
		mxv = t - mnv;
		if(t < mnv)
			mnv = t;	
		for(int i = 2; i < n; i++)
		{
			t = input.nextInt();
			if(t < mnv)
				mnv = t;
			else if(mxv < t - mnv)
				mxv	= t - mnv;
		}
		System.out.println(mxv);
	}
}