#include <bits/stdc++.h>
using namespace std;
const int M = 2e9;
const int N = 3e3 + 5;
int a[100005];
int main() {
  int n;
  cin >> n;
  a[0] = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int x = 0;
  for (int i = n - 1; i >= 1; i--) {
    if (a[i] < a[i + 1]) {
      x = 0;
      while (i >= 1 && x <= 0) {
        x += a[i] - a[i + 1];
        i--;
      }
      if (i == 0) break;
      i++;
    }
  }
  if (x >= 0)
    cout << a[1] << endl;
  else
    cout << a[1] - x << endl;
}
