#include <bits/stdc++.h>
int sol, n, p[100100];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &p[i]);
  sol = p[0];
  int tmp = 0;
  for (int i = 0; i < n - 1; i++) {
    if (p[i] + tmp >= p[i + 1])
      tmp += p[i] - p[i + 1];
    else {
      sol += p[i + 1] - (p[i] + tmp);
      tmp = 0;
    }
  }
  printf("%d\n", sol);
  return 0;
}
