#include <bits/stdc++.h>
int arr[100000], n;
bool check(int start) {
  int state = start - arr[0];
  for (int i = 0; i < n; i++) {
    if (state < 0) return 0;
    if (i == n - 1) return 1;
    state += arr[i] - arr[i + 1];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  int lo = 0, hi = 200000, mid;
  mid = ((long long)hi + lo) / 2;
  int ans = 0;
  while (lo <= hi) {
    if (check(mid)) {
      ans = mid;
      hi = mid - 1;
    } else
      lo = mid + 1;
    mid = ((long long)hi + lo) / 2;
  }
  printf("%d\n", ans);
}
