#include <bits/stdc++.h>
int main() {
  int n;
  int MIN = 0;
  int a, b;
  int first;
  int sum = 0;
  scanf("%d", &n);
  scanf("%d", &a);
  first = a;
  while (--n) {
    scanf("%d", &b);
    sum += (a - b);
    if (sum < MIN) {
      MIN = sum;
    }
    a = b;
  }
  printf("%d\n", first - MIN);
  return 0;
}
