#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    freopen("stacks.in", "r", stdin);
    freopen("stacks.out", "w", stdout);
    int n;
    scanf("%d", &n);
    vector<int> a;
    int ukm;
    scanf("%d", &ukm);
    a.push_back(1);
    ukm = 0;
    for (int i = 1; i < n; ++i)
    {
        int tmp;
        scanf("%d", &tmp);
        if (tmp > 0) 
        {
            a.push_back(1);
            ukm = a.size() - 1;
        }
        else
        {
            if (a.size() == 1) 
            {
                a[0]++;
                continue;
            }
            while (ukm > 0 && a[ukm] == a[ukm - 1]) --ukm;
            ++a[ukm++];
            if (ukm > a.size() - 1)
           	    ukm = a.size() - 1;
        }
    }
    cout << a[0];
}
