#include <bits/stdc++.h>
using namespace std;
long long n, h2, h1, maxx, sum;
int main(void) {
  cin >> n;
  h1 = sum = maxx = 0;
  for (int i = 0; i < n; i++) {
    cin >> h2;
    sum += h2 - h1;
    if (sum > maxx) maxx = sum;
    h1 = h2;
  }
  cout << maxx;
}
