#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using pll = pair<long, long>;
using vi = vector<int>;
using vll = vector<ll>;
using vpi = vector<pi>;
using vpll = vector<pll>;
const int mod = 1e9 + 7;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int last = 0, energy = 0, ans = 0;
  for (int i = int((1)); i <= int((n)); i++) {
    int curr;
    cin >> curr;
    if (curr - last > energy) {
      ans += curr - last - energy;
      energy = 0;
    } else {
      energy -= curr - last;
    }
    last = curr;
  }
  cout << ans << '\n';
  return 0;
}
