#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, v[100010];
  cin >> n;
  v[0] = 0;
  for (int i = 1; i <= n; i++) cin >> v[i];
  int e = 0;
  int c = 0;
  for (int i = 0; i < n; i++) {
    e += v[i] - v[i + 1];
    if (e < 0) {
      c += -e;
      e = 0;
    }
  }
  cout << c << endl;
  return 0;
}
