#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }
int main() {
  long long n;
  cin >> n;
  vector<long long> t(n + 1, 0);
  for (int i = int(0); i < int(n); ++i) cin >> t[i + 1];
  long long need = 0;
  long long e = 0;
  for (int i = int(0); i < int(n); ++i) {
    e += t[i] - t[i + 1];
    if (e < 0) {
      need += -e;
      e = 0;
    }
  }
  cout << need << endl;
  return 0;
}
