#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
void fast() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
int main() {
  fast();
  long long sum = 0;
  int n;
  cin >> n;
  long long x = 0, y;
  long long res = 0;
  while (n--) {
    cin >> y;
    sum += x - y;
    if (sum < 0) {
      res += abs(sum);
      sum = 0;
    }
    x = y;
  }
  cout << res << "\n";
}
