#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int first, second;
  cin >> first;
  int energy = 0, needed = first;
  for (int i = 0; i < n - 1; i++) {
    int temp;
    cin >> temp;
    if (first > temp) {
      energy += first - temp;
    } else {
      if (first < temp) {
        if (energy >= temp - first) {
          energy -= temp - first;
        } else {
          needed += temp - first - energy;
          energy = 0;
        }
      }
    }
    first = temp;
  }
  cout << needed;
}
