#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, n, m, i, j, x, y, k, count = 0, ans = 0;
  cin >> n;
  long long int a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  count += a[0];
  for (i = 0; i < n - 1; i++) {
    if (ans + a[i] - a[i + 1] < 0) {
      count += abs(ans - a[i + 1] + a[i]);
      ans = 0;
    } else {
      ans += a[i] - a[i + 1];
    }
  }
  cout << count;
  return 0;
}
