#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans = 0, a = 0, b, energy = 0;
  while (n--) {
    cin >> b;
    if (energy + a - b < 0) {
      ans += b - a - energy;
      energy = 0;
    } else
      energy += a - b;
    a = b;
  }
  cout << ans;
  return 0;
}
