#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, k = 0, hnext;
  cin >> n;
  int e = 0, t, currenth = 0;
  for (i = 0; i < n; i++, currenth = hnext) {
    cin >> hnext;
    if (hnext < currenth)
      e += currenth - hnext;
    else if (hnext > currenth) {
      if (e >= hnext - currenth)
        e -= hnext - currenth;
      else {
        k += hnext - currenth - e;
        e = 0;
      }
    }
  }
  cout << k;
  return 0;
}
