#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, k, n, m;
  cin >> n;
  long long int re = 0, f = 0;
  long long int cur = 0, pre = 0, sum = 0;
  for (i = 0; i < n; i++) {
    cin >> k;
    long long int req = pre - k;
    sum += req;
    if (sum < 0) {
      re = max(re, -sum);
    }
    pre = k;
  }
  cout << re << "\n";
}
