#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long x;
  long long e = 0;
  long long pos = 0;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    e += (pos - x);
    if (e < 0) {
      ans += (-1) * e;
      e = 0;
    }
    pos = x;
  }
  cout << ans << endl;
  return 0;
}
