#include <bits/stdc++.h>
using namespace std;
long long int a, s, d, f, g;
int main() {
  cin >> a;
  for (int i = 0; i < a; i++) {
    cin >> s;
    d += f - s;
    if (d < 0) g -= d, d = 0;
    f = s;
  }
  cout << g;
}
