#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  h[-1] = 0;
  int current_dollar = 0, energy = 0;
  for (int i = 0; i < n; i++) {
    energy += (h[i - 1] - h[i]);
    if (energy < 0) {
      current_dollar += -energy;
      energy = 0;
    }
  }
  cout << current_dollar << endl;
}
