#include <bits/stdc++.h>
using namespace std;
int arr[100005], ans, sum, n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  ans = arr[0];
  sum = 0;
  for (int i = 0; i < n - 1; i++) {
    sum += (arr[i] - arr[i + 1]);
    if (sum < 0) ans += abs(sum), sum = 0;
  }
  cout << ans << endl;
  return 0;
}
