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

