#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b = 0, d;
  cin >> a;
  int c[a];
  for (int i = 0; i <= a; i++) {
    cin >> c[i];
    if (c[i] < b)
      d += d - c[i];
    else
      d = c[i];
  }
  cout << d;
  return 0;
}
