#include <bits/stdc++.h>
using namespace std;
int main()
{
	ifstream fi("DE001_3.INP");
	ofstream fo("DE001_3.OUT");
	long int n;
    fi>>n;
    long int a[n];
	long int max=0;
    for(long int i=0;i<n;i++)
    {
       fi>>a[i];
       if (a[i]<0){max=a[i];}
     }
   fi.close();
   for(long int i=0;i<n;i++)
    { 
        if(a[i]<0 &&a[i]>max)        
        {max=a[i];}
   }
   fo<<max;
   fo.close();
}
