#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int h[N];
int main() {
  int n, e, ans, i, t;
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < n + 2; i++) h[i] = 0;
    for (i = 1; i <= n; ++i) scanf("%d", &h[i]);
    ans = 0;
    for (i = e = 0; i < n; ++i) {
      if (h[i] + e < h[i + 1]) {
        t = (h[i + 1] - e - h[i]);
        h[i] += t;
        ans += t;
      }
      e += (h[i] - h[i + 1]);
    }
    printf("%d\n", ans);
  }
  return 0;
}
