#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int cost = 0;
  int oldh, h, energy;
  cin >> h;
  cost = h;
  energy = 0;
  oldh = h;
  for (int i = 1; i < n; ++i) {
    cin >> h;
    if (h > oldh) {
      if (energy < h - oldh) {
        cost += h - oldh - energy;
        energy = 0;
      } else {
        energy -= h - oldh;
      }
    } else {
      energy += oldh - h;
    }
    oldh = h;
  }
  cout << cost;
}
