#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, e = 0, sol = 0, x = 0, y;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> y;
    e += x - y;
    if (e < 0) {
      sol += abs(e);
      e = 0;
    }
    x = y;
  }
  cout << sol;
}
