#include <bits/stdc++.h>
using namespace std;
unsigned long long int power(unsigned long long int n,
                             unsigned long long int p) {
  unsigned long long int m = 1;
  while (p > 0) {
    m *= n;
    p--;
  }
  return m;
}
void sieveOfEratosthenes(int n, bool prime[]) {
  int i, p;
  for (i = 2; i * i <= n; i++) {
    if (prime[i]) {
      for (p = i * i; p <= n; p += i) prime[p] = false;
    }
  }
}
long long int coins(int n, int a[]) {
  int res, mn = INT_MAX;
  res = mn = -a[0];
  for (int i = 0; i < n - 1; ++i) {
    mn = min(mn, res);
    res += a[i] - a[i + 1];
  }
  return max(abs(res), abs(mn));
}
int main() {
  int t, i, n, m, d, k, p;
  long long int l, r, ret;
  cin >> n;
  int arr[n];
  for (i = 0; i < n; i++) cin >> arr[i];
  cout << coins(n, arr);
  return 0;
}
