#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k = 0;
  cin >> n;
  int a[n];
  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cnt = 0;
  ans = a[0];
  for (int i = 1; i < n; i++) {
    cnt = cnt + (a[i - 1] - a[i]);
    if (cnt <= 0) {
      ans = ans - (cnt);
      cnt = 0;
    }
  }
  cout << ans << endl;
}
