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