#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  int n, a, b;
  t = 1;
  while (t--) {
    a = b = 0;
    scanf("%d", &n);
    int arr[n];
    for (int i = 0; i < n; i++) {
      scanf("%d", &arr[i]);
    }
    b -= arr[0];
    for (int i = 0; i < n - 1; i++) {
      if (b < 0) a = max(a, abs(b));
      if (arr[i] >= arr[i + 1])
        b += (arr[i] - arr[i + 1]);
      else
        b -= (arr[i + 1] - arr[i]);
    }
    a = max(a, abs(b));
    printf("%d\n", a);
  }
  return 0;
}
