#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int currentEnergy = 0;
  int amountPaid = 0;
  int ph = 0;
  for (int i = 0; i < n; i++) {
    int EnergyRequired = arr[i] - ph;
    currentEnergy -= EnergyRequired;
    if (currentEnergy < 0) {
      amountPaid -= currentEnergy;
      currentEnergy = 0;
    }
    ph = arr[i];
  }
  cout << amountPaid;
}
