#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const double pi = acos(-1.0);


int main() {
    freopen("handshakes.in", "r", stdin);
    freopen("handshakes.out", "w", stdout);

    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++)
    	cin >> a[i];
    int ans = 0;
    int cnt = 0;
    for (int i = n - 1; i >= 0; i--) {
		ans = max(ans, a[i] + cnt);
		cnt += (a[i] > 0);    	
    }

    cout << ans << endl;

    return 0;
}