#include <fstream>
using namespace std;
int main()
{
    ifstream f1("SOAM.inp");
    ofstream f2("SOAM.out");
    int i,j,sln = 0,x = 0;
    f1 >> i;
    for (int n = 1; n <= i; n++)
    {
        f1 >> j;
        if (j > 0) continue;
        if (x == 0)
        {
            sln = j;
            x = 1;
        }
        else
        {
            if (sln < j) sln = j;
        }
    }
    f1.close();
    f2 << sln;
    f2.close();
    return 0;
}
