#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, h, on = 0, ans = 0, E = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> h;
    if (h > on) {
      if (E >= h - on) {
        E -= (h - on);
        on = h;
      } else {
        ans += h - on - E;
        E = 0;
        on = h;
      }
    } else {
      E += on - h;
      on = h;
    }
  }
  cout << ans;
  return 0;
}
