#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, a[100005], d = 0, n, dmin;
  cin >> n >> x;
  d -= x;
  dmin = d;
  for (int i = 2; i <= n; i++) {
    cin >> y;
    d += x - y;
    dmin = min(d, dmin);
    x = y;
  }
  cout << -dmin;
  return 0;
}
