#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x, y = 0, c = 0, e = 0;
  while (n--) {
    cin >> x;
    if (e + y - x < 0) {
      c += x - y - e;
      e = 0;
    } else
      e = e + y - x;
    y = x;
  }
  cout << c;
  return 0;
}
