#include <bits/stdc++.h>
using namespace std;
int h[100010];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &h[i]);
  h[0] = 0;
  long long ans = 0;
  long long cnt = 0;
  for (int i = 1; i <= n; i++) {
    cnt += h[i - 1] - h[i];
    ans = min(ans, cnt);
  }
  printf("%I64d\n", -ans);
  return 0;
}
