#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, num, ans = 0, now = 0, r = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &num);
    r = r + (now - num);
    if (r < 0) {
      ans = ans - r;
      r = 0;
    }
    now = num;
  }
  printf("%d\n", ans);
  return 0;
}
