#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> v(n + 1);
  v[0] = 0;
  for (long long int i = 1; i <= n; i++) {
    cin >> v[i];
  }
  long long int ans = 0;
  long long int cnt = v[0];
  for (long long int i = 0; i < n; i++) {
    if (v[i] <= v[i + 1]) {
      long long int g = abs(v[i + 1] - v[i]);
      if (ans - g < 0) {
        cnt = cnt + (v[i + 1] - v[i] - ans);
        ans = 0;
      } else
        ans = ans - g;
    } else {
      ans = ans + v[i] - v[i + 1];
    }
  }
  cout << cnt;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) solve();
  return 0;
}
