#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define sc(n) scanf("%d", &n)
#define sf scanf
#define pf printf
#define MX 100005
typedef long long ll;
int a[MX];
int main()
{
int i, n;
int paid, e;
while(sc(n)==1)
{
e = 0;
paid = 0;
a[0] = 0;
for(i=1; i<=n; i++)
sc(a[i]);
for(int i=0; i<n;i++)
{
e += (a[i] - a[i+1]);
if(e<0)
paid += -e , e = 0;
}
pf("%d\n", paid);
}
return 0;
}
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define sc(n) scanf("%d", &n)
#define sf scanf
#define pf printf
#define MX 100005
typedef long long ll;
int a[MX];
int main()
{
int i, n;
int paid, e;
while(sc(n)==1)
{
e = 0;
paid = 0;
a[0] = 0;
for(i=1; i<=n; i++)
sc(a[i]);
for(int i=0; i<n;i++)
{
e += (a[i] - a[i+1]);
if(e<0)
paid += -e , e = 0;
}
pf("%d\n", paid);
}
return 0;
}