#include <bits/stdc++.h>
using namespace std;
void rec(int arr[], int n, int energy, int money, int curr) {
  if (curr == n) {
    cout << money;
    return;
  }
  if (arr[curr] >= arr[curr + 1]) {
    energy += arr[curr] - arr[curr + 1];
  } else if (arr[curr] < arr[curr + 1]) {
    if (energy >= (arr[curr + 1] - arr[curr])) {
      energy -= (arr[curr + 1] - arr[curr]);
    } else {
      money += arr[curr + 1] - arr[curr] - energy;
      energy = 0;
    }
  }
  rec(arr, n, energy, money, curr + 1);
}
int main() {
  int i, n, arr[100001];
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  arr[0] = 0;
  int energy = 0;
  int money = 0;
  rec(arr, n, energy, money, 0);
}
