#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("date.in","r",stdin);
freopen("date.out","w",stdout);
#endif
int x = 0, y, n, sol = 0,energy = 0;
cin >> n;
for(int i = 1;i <= n; ++i)
{
cin >> y;
energy += x-y;
if(energy < 0){
sol += -energy;
energy = 0;
}
x = y;
}
cout<<sol<<"\n";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGlvPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQp7CiAgICAjaWZuZGVmIE9OTElORV9KVURHRQogICAgICAgIGZyZW9wZW4oImRhdGUuaW4iLCJyIixzdGRpbik7CiAgICAgICAgZnJlb3BlbigiZGF0ZS5vdXQiLCJ3IixzdGRvdXQpOwogICAgI2VuZGlmCiAgICBpbnQgIHggPSAwLCB5LCBuLCBzb2wgPSAwLGVuZXJneSA9IDA7CiAgICBjaW4gPj4gbjsKICAgIGZvcihpbnQgaSA9IDE7aSA8PSBuOyArK2kpCiAgICB7CiAgICAgICAgY2luID4+IHk7CiAgICAgICAgZW5lcmd5ICs9IHgteTsKICAgICAgICBpZihlbmVyZ3kgPCAwKXsKICAgICAgICAgICAgc29sICs9IC1lbmVyZ3k7CiAgICAgICAgICAgIGVuZXJneSA9IDA7CiAgICAgICAgfQogICAgICAgIHggPSB5OwogICAgfQogICAgY291dDw8c29sPDwiXG4iOwogICAgcmV0dXJuIDA7Cn0K