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