#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, money = 0, energy = 0, x;
  cin >> n;
  int* arr = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> x;
    arr[i] = x;
  }
  money += arr[0];
  for (int i = 0; i < n - 1; i++) {
    int h = arr[i] - arr[i + 1];
    energy = energy + h;
    while (energy < 0) {
      energy++;
      money++;
    }
  }
  cout << money << endl;
  return 0;
}
