#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 energy = 0;
  int sol = arr[0];
  energy = 0;
  for (int i = 0; i < n - 1; i++) {
    energy += (arr[i] - arr[i + 1]);
    if (energy < 0) {
      sol += abs(energy);
      energy = 0;
    }
  }
  cout << sol << endl;
}
