#include <bits/stdc++.h>
using namespace std;
const int M = 100000 + 10;
int d[M];
int n, ans, temp;
int main() {
  while (scanf("%d", &n) == 1) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &d[i]);
    }
    ans = temp = 0;
    for (int i = 1; i < n; i++) {
      temp += d[i] - d[i + 1];
      if (temp < 0) {
        ans -= temp;
        temp = 0;
      }
    }
    printf("%d\n", ans + d[1]);
  }
  return 0;
}
