#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0, -1, -1, 1, 1};
int dy[] = {0, 0, 1, -1, -1, 1, -1, 1};
int main() {
  int t = 0, z = 0, len;
  int n, k = 0, m = 0, bam = 0, dan = 0, ans = 0;
  scanf("%d", &n);
  int a[n];
  for (int l = 1; l < n + 1; l++) scanf("%d", &a[l]);
  a[0] = 0;
  for (int l = 0; l < n; l++) {
    k += (a[l] - a[l + 1]);
    if (k < 0) {
      ans += abs(k);
      k = 0;
    }
  }
  printf("%d", ans);
  return 0;
}
