#include <bits/stdc++.h>
using namespace std;
int sum[100010];
int main() {
  int n;
  cin >> n;
  int pre = 0;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    sum[i] = (pre - a);
    pre = a;
  }
  long long tmp = 0;
  for (int i = 1; i <= n; i++) {
    if (tmp + sum[i] > 0) {
      tmp = 0;
    } else {
      tmp += sum[i];
      ans = min(ans, tmp);
    }
  }
  cout << -ans << endl;
  return 0;
}
