#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y) {
  long long int result = 1;
  while (y) {
    if (y % 2 == 1) result = (result * x);
    y = y / 2;
    x = (x * x);
  }
  return result;
}
int main() {
  long long int n, i, j, k, dollars, p, x, y, energy, dif;
  cin >> n;
  int a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  dollars = energy = 0;
  p = 0;
  for (i = 0; i < n; i++) {
    if (p < a[i]) {
      dif = a[i] - p;
      if (energy >= dif)
        energy -= dif;
      else {
        dollars += (dif - energy);
        energy = 0;
      }
    } else {
      energy += (p - a[i]);
    }
    p = a[i];
  }
  cout << dollars << endl;
  return 0;
}
