#include <bits/stdc++.h>
int x[100001] = {0};
int main() {
  int i, n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x[i]);
  }
  int sum = 0;
  int cn = 0;
  for (i = 0; i < n; i++) {
    sum = sum + x[i] - x[i + 1];
    if (sum < 0) {
      do {
        cn++;
        sum++;
      } while (sum < 0);
    }
  }
  printf("%d", cn);
  return 0;
}
