#include <bits/stdc++.h>
using namespace std;
int main() {
  int size;
  cin >> size;
  vector<int> dollars(size + 1);
  dollars[0] = 0;
  int sum = 0;
  int energy = 0;
  for (int i = 1; i <= size; i++) {
    cin >> dollars[i];
    sum += dollars[i - 1] - dollars[i];
    if (sum < 0) {
      energy += abs(sum);
      sum = 0;
    }
  }
  cout << abs(energy) << endl;
  return 0;
}
