#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h, a = 0, b, money = 0, energy = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> h;
    b = h;
    if (a > b)
      energy = energy + (a - b);
    else if ((a < b) && (energy != 0)) {
      if ((b - a) <= energy)
        energy = energy - (b - a);
      else {
        money = money + (b - a - energy);
        energy = 0;
      }
    } else if ((a < b) && (energy == 0))
      money = money + (b - a);
    a = b;
  }
  cout << money << endl;
  return 0;
}
