#include <bits/stdc++.h>
using namespace std;
int n, h[100010], nl, t;
void nhap() {
  t = h[0] = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
    t = max(h[i], t);
  }
}
void cbi() {}
void xuli() {
  int l = 0, r = t + 1, g, ok;
  while (l < r - 1) {
    nl = ok = 0;
    g = (l + r) >> 1;
    h[0] = g;
    for (int i = 0; i < n; i++) {
      nl += h[i] - h[i + 1];
      if (nl < 0) {
        ok = 1;
        break;
      }
    }
    if (ok)
      l = g;
    else
      r = g;
  }
  cout << r;
}
void ghikq() {}
int main() {
  nhap();
  cbi();
  xuli();
  ghikq();
  return 0;
}
