#include <bits/stdc++.h>
using namespace std;
const long long int modu = 1e9 + 7;
int noofdig(int N) { return floor(log10(N)) + 1; }
int bits_count(unsigned int u) {
  unsigned int uCount;
  uCount = u - ((u >> 1) & 033333333333) - ((u >> 2) & 011111111111);
  return ((uCount + (uCount >> 3)) & 030707070707) % 63;
}
long long int f(long long int a) { return 0; }
void pre() {}
void solve() {
  int n;
  cin >> n;
  int spent = 0;
  int energy = 0;
  int inp;
  int curr = 0;
  for (int i = 0; i < n; ++i) {
    cin >> inp;
    energy += curr - inp;
    if (energy < 0) {
      spent += (0 - energy);
      energy = 0;
    }
    curr = inp;
  }
  cout << spent << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
}
