#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  int h[100010], a[100010];
  h[0] = 0;
  int m = 0;
  cin >> n;
  h[0] = 0;
  a[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
    a[i] = a[i - 1] + (h[i - 1] - h[i]);
    m = min(a[i], m);
  }
  cout << abs(m);
  return 0;
}
