#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[100005], res = 0, e = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  res += a[0];
  for (int i = 0; i < n - 1; i++) {
    if ((e + (a[i] - a[i + 1])) < 0) {
      res += abs(e + a[i] - a[i + 1]);
      e = 0;
    } else
      e += (a[i] - a[i + 1]);
  }
  cout << res << endl;
  return 0;
}
