#include <fstream>
using namespace std;
int main(int argc, char** argv) 
{
	ifstream f("DE001_3.inp");
	long long n,dem=0,max=-100000;
	int i;
	f>>n;
	long long a[10000];
	for (i=1;i<=n;i++)
	{f>>a[i];}
	f.close();
	ofstream g("DE001_3.out");
	for (i=1;i<=n;i++)
	{
		if (a[i]<0)
		{
			{
				if (a[i]>max)
				max=a[i];
			}
			dem++;
		}
	}
	if (dem!=0)
	g<<max;
	else
	g<<"0";
	return 0;
}
