#include <bits/stdc++.h>
using namespace std;
int n;
int h[100005];
bool test(int a) {
  int energy = 0;
  for (int i = 0; i < n; i++) {
    energy += a - h[i];
    a = h[i];
    if (energy < 0) return true;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int a = -1;
  for (int b = n + 1; b >= 1; b /= 2) {
    while (test(a + b)) a += b;
  }
  cout << a + 1;
}
