#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a = 0, b, energy = 0, sum = 0;
  cin >> n;
  for (auto i = 0; i <= n; i++) {
    cin >> b;
    energy += (a - b);
    sum += max(-energy, 0);
    energy = max(energy, 0);
    a = b;
  }
  cout << sum;
  return 0;
}
