#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int A[n + 1];
  A[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    cin >> A[i];
  }
  int dollar = A[1];
  int cou = 0;
  for (int i = 1; i < n; i++) {
    cou = cou + A[i] - A[i + 1];
    if (cou < 0) {
      dollar = dollar + abs(cou);
      cou = 0;
    }
  }
  cout << dollar;
}
