#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int x = 0;
  int all = 0, cur = 0;
  for (int i = 1; i <= n; ++i) {
    int diff = a[i - 1] - a[i];
    if (cur + diff < 0) {
      all += -(diff + cur);
      cur = 0;
    } else
      cur += diff;
  }
  cout << all;
  return 0;
}
