#include <iostream>
#include <vector>
#include <cassert>

int main() {
	int N, c = 0, D = 0, V;
	std::vector<int> A;
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		std::cin >> A[i];
	}
		for (int j = 0; j < N; j++) {
			V = j;
			while (V < N) {
				//bool b = A[j].empty();
				if (A[j].empty() == "false") {
				D = A[j];
				if (D == 0) {
					c++;
					D = 0;
				}
				V++;
			}
			}

	std::cout << c << std::endl;
	
	
	
	
	return 0;
}