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