#include <bits/stdc++.h>
using namespace std;
const long double pi = atan(1) * 4;
bool by2(const pair<long long, long long> a,
         const pair<long long, long long> b) {
  return (a.second > b.second);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, c = 0, r = 0;
  cin >> n;
  long long h[n + 1];
  h[0] = 0;
  for (int i = 0; i < n; i++) cin >> h[i + 1];
  for (int i = 0; i < n; i++) {
    if (h[i] - h[i + 1] < 0) {
      if (abs(h[i] - h[i + 1]) > r) {
        c += abs(h[i] - h[i + 1]) - r;
      }
      r -= min(abs(h[i] - h[i + 1]), r);
    } else {
      r += (h[i] - h[i + 1]);
    }
  }
  cout << c;
}
